`

CSS语法

阅读更多

样式规则——告诉浏览器如何渲染网页上的特定元素

 

声明之间用“;”间隔。

一个声明一个属性。

选择器分组——每个的路径均要求写全,用“,”分割

 

 

 

 

 

 

 

 

 

选择器分类

元素选择器(标记名{……})

——没有层次,全局

<style type="text/css"> div{……}</style>

ID选择器(#id名{……})

无层次,唯一定位(id唯一)

<style type="text/css">#big{……}</style>

<table id="big">……</>

类选择器(.类名{……})

有某个class属性的任何元素;多个类可以作用于一个元素

<p class="big font size">……</p>

<style type="text/css">.big{……}</style>

通配符选择器(*{……})

含通配符页面的一切(包括在 text里输入的内容)

<style type="text/css">*{……}</style>

包含选择器(x y{……})

细微定位,x、y是任何类型的选择器

<style type="text/css">选择器(标记名){……}</style>

伪类选择器(选择器:伪类{……})

超链接的伪类选择器是通用的

<style type="text/css">a{……} (设置超链接)

                       a:link{text-decoration:line-through}未访问的)

                       a:visited{……}(已经访问过)

                       a:hover{……}(光标停于超链接)

                       a:active{……}(得到焦点如被点击)</style>

伪元素选择器

格式化一个元素内容的第一个字母(标记:first-letter{……})或者第一行(标记:first-line{……})、伪元素(beforeafter)与属性(content)用于元素的两边

<style type="text/css">p:first-line{fonft-weight:bold;}</style>

<style type="text/css">p:first-letter{font-size:200%;font-weight:bold;}</style>

<style type="text/css">blockquote:before { content: open-quote; } blockquote:after { content: close-quote; }

</style>

  • 大小: 37.3 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics