任务7

2017-10-12  本文已影响0人  dongguazhon

1.class和id的使用场景?

2.CSS选择器常见的有几种?

3.选择器的优先级是怎样的?对于复杂场景如何计算优先级?

!important>内联样式>id选择器>类选择器>伪类选择器>属性选择器>标签选择器>通配符选择器

复杂场景!important权重为1000,id选择器权重为100,类选择器权重为10,标签选择器权重为1,对于复杂样式,将各选择器对应的权重相加,权重高的优先

4.a:link, a:hover, a:active, a:visited 的顺序是怎样的? 为什么?

5.以下选择器分别是什么意思?

}
.header{                //选中class为header的元素
}
.header .logo{      //选中class为header的元素下class为logo的元素
}
.header.mobile{      //选中class同时为header和mobile的元素
}
.header p, .header h3{   //选中class为header下的所有p标签和h3标签
}
#header .nav>li{           //选中id为header元素下 class为nav下的所有li元素
}
#header a:hover{          //选中id为header元素下 所有a标签鼠标划过时的状态
}
#header .logo~p{         //选中id为header元素下 class为logo元素之后同级的所有p元素
}
#header input[type="text"]{       //选中id为header元素下  <input type="text">的元素
}

div:first-child和div:first-of-type的作用和区别

运行如下代码,解析下输出样式的原因。

.item1:first-child{
  color: red;
}
.item1:first-of-type{
  background: blue;
}
</style>
 <div class="ct">
   <p class="item1">aa</p>
   <h3 class="item1">bb</h3>
   <h3 class="item1">ccc</h3>
 </div>
上一篇 下一篇

猜你喜欢

热点阅读