任务7

2017-08-15  本文已影响0人  饥人谷_星璇

1.class 和 id 的使用场景?

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

1.基础选择器
2.组合选择器
3.属性选择器
4.伪类选择器
5.伪元素选择器

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

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

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

#header{
} ------  选择id为header的元素
.header{
} ------  选择class为header的元素  
.header .logo{
} ------ 选择class为header的元素后代中class为logo的元素
.header.mobile{
} ------ 选择class为header的元素和class为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的元素后代中type属性为text的input元素

6.列出你知道的伪类选择器

选择器 含义
E:first-child 匹配作为长子(第一个子女)的元素E
E:link 匹配所有未被点击的链接
E:visited 匹配所有已被点击的链接
E:active 匹配鼠标已经其上按下、还没有释放的E元素
E:hover 匹配鼠标悬停其上的E元素
E:focus 匹配获得当前焦点的E元素
E:lang(c) 匹配lang属性等于c的E元素
E:enabled 匹配表单中可用的元素
E:disabled 匹配表单中禁用的元素
E:checked 匹配表单中被选中的radio或checkbox元素
E::selection 匹配用户当前选中的元素

7.div:first-child、div:first-of-type、div :first-child和div :first-of-type的作用和区别 (注意空格的作用)

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

<style>
.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>

输出的样式为

image.png
上一篇下一篇

猜你喜欢

热点阅读