最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
css after hover not 伪类选择
时间:2011-04-14 编辑:简简单单 来源:一聚教程网
一、x:after
.clearfix:after {
content: “”;
display: block;
clear: both;
visibility: hidden;
font-size: 0;
height: 0;
}
.clearfix {
*display: inline-block;
_height: 1%;
}
我想上面这段代码,很多朋友都非常熟悉,是清理浮动时常用的hack方法。:after伪类与content结合使用,用于往元素类追加内容。:after伪类还有个妙用:用于产生阴影,点击这里查看。
二、x:hover
div:hover {
background: #e3e3e3;
}
hover在前面的文章中已经介绍过,ie6下只支持a的hover。
即使用border-bottom: 1px solid black; 要好于text-decoration: underline;
从实际的效果来看,使用border-bottom的距离比text-decoration来的合理,但使用border-bottom存在一些风险,比如颜色问题。
三、x:not(selector)
div:not(#container) {
color: blue;
}
否定伪类选择器,这还是比较好理解的,上述将会把非id为container的div的字体颜色设置为蓝色。
:not伪类ie8并不支持,ie9已经支持了。
四、x::ps教程eudoelement
p::first-line {
font-weight: bold;
font-size: 1.2em;
}
::伪类,用于给元素的片段添加样式,这如何理解呢?比如你要让一个段落的第一行的文字加粗,那么这个选择器是不二之选。
除此之外,你还可以给第一个字加上特殊样式,这个应用还是非常常见的
p::first-letter {
float: left;
font-size: 2em;
font-weight: bold;
font-family: cursive;
padding-right: 2px;
}
相关文章
- css 伪类的使用方法详解 04-20
- CSS伪类:before, :after详解 03-26
- css 伪类――动态链接 07-17
- 利用vbs类实现css按钮,建议入精华 01-18
- CSS教程 10、CSS的Pseudo Classes 伪类 01-11
- CSS样式表中的类 01-11