css3更新的颜色

RGBA:红、绿、蓝、不透明度
rgba(89,0,127,0.4);
HSL和HSLA:色相、饱和度、亮度、不透明度
hsl(282,100%,25%);
hsl(282,100%,25%,.75);
使用与媒体相关的样式表
link或style:添加属性media属性
有all、aural、braille、handheld、print、projection(投影设备)、screen、tty、tv
@media print{
body{
font-size:25pt;
}
p{
color:#000;
}
}
定义选择器
h1{
color:red;
}
h1 em{
color:red;
}
.error{
color:red;
}
#gaudi{
color:red;
}
strong.error{
color:red;
}
a:link{
color:red;
}
a[title]{
color:red;
}
a[href="http://xxx.com"]{
color:red;
}
只选择一代子元素:子子元素、非子子元素等不会选中
.architect > p {
color:red;
}
相邻同胞结合符:不必是同一种元素类型,只要彼此相邻就可以
.architect p+p{
color:red;
}
普通同胞结合符:选择并非直接出现在另一同胞元素,可以直接相邻,也可以不直接相邻
h1~h2{
color:red;
}
选择某元素第一个和最后一个子元素
li:first-child{
color:red;
}
li:last-child{
color:red;
}
选择某元素第一个字母或者第一行
p:first-line{
color:red;
}
p:first-letter{
color:red;
}
第n个子元素
li:nth-child(3){
color:red;
}
li:nth-last-child(2){
color:blue;
}
li:nth-child(4n+1){
color:bule;
}
奇偶
li:nth-last-child(odd){
color:blue;
}
li:nth-last-child(even){
color:blue;
}
h2:nth-of-type(odd){
color:red;
}
只有一个子元素
li:only child{
color:red;
}

伪元素、伪类
//是HTML并不存在的元素,并未在HTML中作相应的标记,是另一个元素的部分内容
::first-line
::first-letter
::before
::after
:first-child
:link
:hover

按状态选择链接
a:link{
color:red;
}
a:visited{
color:orange;
}
a:focus{
color:purple;
}
a:hover{
color:green;
}
a:active{
color:blue;
}
按属性选择元素
[attribute]
[attribute="value"]
[attribute~="value"]
artcle[class~="barcelona"]{
color:red;
}
[attribute|="value"]
h2[lang|="es"]{
color:red;
}
[attribute^="value"]
a[href^="http://"]{
color:orange;
}
[attribute$="value"]
img[src="logo.png"]{
border:1px solid green;
}
[attribute*="value"]
a[href][title*="how"]{
color:red;
}

结构性伪类选择器
root,not,empty,target
允许根据文档中的结构来指定元素样式
:root{
background:red;
}
div *:not(h1){
coloe:red;
}
:empty{
background:red;
}
:target{
background:red;
}
UI元素状态伪类选择器
css3中,有17种UI元素伪类选择器
input[type="text"]:hover{
color:red;
}
input[type="text"]:focus{
color:red;
}
input[type="text"]:active{
color:red;
}
input[type="checkbox"]:checkbox{
color:red;
}
enabled和disabled
input[type="text"]:enable{color:red;}
input[type="text"]:disabled{color:black}

|