展会信息港展会大全

css after hover not 伪类选择
来源:互联网   发布日期:2016-03-25 15:54:56   浏览:2117次  

导读:一、x:after .clearfix:after { content: “”; display: block; clear: both; visibility: hidden; font-size: 0; height: 0; } .clearfix { *display: inline-block; _height: 1%; } 我想上面这段代码,很多朋友都非常熟悉,是清理浮动时常用的hack方法。:...

一、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;

}

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港