您的位置:首页 > Web前端 > CSS

css标签选取属性

2016-08-16 10:24 239 查看
:first-child(首个子对象)

p:first-child {font-weight: bold;}

li:first-child {text-transform:uppercase;}

p:nth-child(2)

在下面的例子中,选择器匹配所有
元素中的第一个 元素:

p > i:first-child {

font-weight:bold;

}


在下面的例子中,选择器匹配所有作为元素的第一个子元素的
元素中的所有 元素:

p:first-child i {

color:blue;

}


“first-line” 伪元素用于向文本的首行设置特殊样式。

在下面的例子中,浏览器会根据 “first-line” 伪元素中的样式对 p 元素的第一行文本进行格式化:

p:first-line

{

color:#ff0000;

font-variant:small-caps;

}

:first-letter 伪元素

“first-letter” 伪元素用于向文本的首字母设置特殊样式:

p:first-letter

{

color:#ff0000;

font-size:xx-large;

}

CSS2 - :before 伪元素

“:before” 伪元素可以在元素的内容前面插入新内容。

下面的例子在每个

元素前面插入一幅图片:

h1:before

{

content:url(logo.gif);

}

CSS2 - :after 伪元素

“:after” 伪元素可以在元素的内容之后插入新内容。

下面的例子在每个

元素后面插入一幅图片:

h1:after

{

content:url(logo.gif);

}

规定属于其父元素的第二个子元素的每个 p 的背景色:

p:nth-child(2)

{

background:#ff0000;

}

transition: 0.5s all ease;

-webkit-transition: 0.5s all ease;

-moz-transition: 0.5s all ease;

-o-transition: 0.5s all ease;

-ms-transition: 0.5s all ease;

body a {

transition: all 0.5s ease 0s;

}

背景颜色渐变

li:last-child{background:none;}…

prev

next
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: