10月08, 2018

css学习笔记

一些标签

<dl>
    <dt>
    </dt>
    <dd>
    </dd>
</dl>
<caption>
</caption>
<blockquato>
</blockquato>

属性选择器

// 1. 存在选择器
p[title]
// 2. 单词选择器
p[title~="paragraph"]
// 3. 值选择器
p[title="hello"]
// 4. 正则匹配
p[title^=val](以val开始)
p[title$=end](以end结尾)
p[title*=val](包含val)

伪类

p:first-of-child {

}
p:first-of-type {

}
p:nth-of-type(2):hover {

}

first-child和first-of-type区别?

<div>
    <p>
        这是p元素
    </p>
    <h1>标题一</h1>
    <span>第3个子元素</span>
</div>

A:first child匹配某父元素的第一个子元素。first of type 匹配父元素的第一个该类型的元素。

  • p:first-of-type √
  • h1:first-of-type √
  • p:first-of-child √
  • h1:first-of-child ×

继承

? css继承的4个值

  • inherit 与父元素一致
  • initial 浏览器默认样式,有可能与父元素一致
  • unset 自然值,如果可继承,则为inherit,否则像initial
  • revert 如果没有应用任何样式,否则属性值被设置成用户代理的默认样式。

元素匹配顺序

  • 千位:如果声明是在style 属性中该列加1分(这样的声明没有选择器,所以它们的专用性总是1000。)否则为0。
  • 百位:在整个选择器中每包含一个ID选择器就在该列中加1分。
  • 十位:在整个选择器中每包含一个类选择器、属性选择器、或者伪类就在该列中加1分。
  • 个位:在整个选择器中每包含一个元素选择器或伪元素就在该列中加1分。

本文链接:http://fengbaiyang.cn/post/css-learn-01.html

-- EOF --

Comments

暂不支持评论,如有问题,请发邮件至baiyang.feng@outlook.com。 望不吝赐教~