CSS3新增伪类用法

1.:first-of-type p:first-of-type 选择属于其父元素的首个p元素的每个p元素。 2.:last-of-type p:last-of-type 选择属于其父元素的最后p元素的每个p元素。 3.:nth-of-type() p:nth-of-type(n) 选择属于其父元素的第n个p元素的每个p元素。 4.:nth-last-of-type() p:nth-last-of-type(n)选择属于其父元素的倒数第n个p元素的每个p元素。

这是一个标题

这是第一个段落。

//当前选中元素

这是第二个段落。

这是第三个段落。

这是第四个段落。

5.:only-of-type p:only-of-type 选择属于其父元素唯一的p元素的每个p元素。

This is a paragraph.

//当前选中元素

This is a paragraph.

This is a paragraph.

This is a paragraph.

6.:only-child p:only-child 选择属于其父元素的唯一子元素的每个p元素。(即p是唯一的子元素)

This is a paragraph.

//当前选中元素

This is a paragraph.

This is a paragraph.

7.:nth-child() p:nth-child(n) 指定每个 p 元素匹配的父元素中第 n 个子元素 8.:nth-last-child() p:nth-child(n) 指定每个 p 元素匹配的父元素中倒数第 n 个子元素

这是一个标题

这是第一个段落。

//当前选中元素

这是第二个段落。

这是第三个段落。

这是第四个段落。

注意: Internet Explorer 8 以及更早版本的浏览器不支持 :nth-child()选择器.

9.表单控件的状态,:enabled :disabled :checked

本文章由javascript技术分享原创和收集

发表评论 (审核通过后显示评论):

昵称:
邮箱:
内容: