学习记录,够用即可
/*标签选择器*/
h1 {
color: red;
}
/*子代选择 h1>h2*/
/*同代选择 h1~h2*/
/*相邻选择 h1+h2*/
/*class类选择器*/
.h1-class {
color: orange;
}
/*id选择器*/
#h1-id {
color: yellow;
}
/*属性选择,可以指定多个,如h1[title][class],
也可以指定属性的值 如h1[title="h1"]
属性值可以使用正则匹配 如:^=表示开头匹配 $=表示结尾匹配 *=表示包含匹配 ~=表示单词匹配 |=表示结尾或-结尾匹配*/
h1[title] {
color: green;
}
/*伪类选择器*/
a:link {
color: blue;
font-size: xx-large;
}
a:visited {
color: blue;
}
a:hover {
color: yellow;
}
a:active {
color: green;
}
input:focus {
color: red;
}
input:target{
}
input:empty{
/*display: none;*/
}
/*标签限定位置的伪类*/
h1 h2:first-child{
/*第一个标签是h2 last同理*/
}
h1 h2:first-of-type{
/*出现的第一个h2 last同理*/
}
h1 h2:only-of-type{
/*唯一的*/
}
h1 h2:nth-child(2){
/*限定为第二个* last同理/
}
h1 h2:nth-of-type(2){
/*第二个出现的* last同理/
}
/*一个样式可以对应多个标签 如:h1,h2,.class*/
/*一个标签也可以对应多个样式 如:<h1 class="class1 class2"></h1>*/
此处评论已关闭