css 伪元素 :before,:after 用法,在ie下有效果,在火狐,谷歌下失效,大神帮忙看看. 20
html:<divclass="artTitle"><a>thisisatest</a></div>css:.artTitle{width:90%;margin-top:...
html:
<div class="artTitle"><a>this is a test</a></div>
css:
.artTitle
{
width:90%;
margin-top:10px;
height:45px;
font-size:20px;
padding:0 5%;
position:relative;
overflow:hidden;
}
.artTitle a::before,.artTitle a::after
{
content:" ";
position:absolute;
display:block;
width:0px;
height:45px;
background:#E3E3E3;
transition:width 0.2s linear;
-webkit-transition:width 0.2s linear;
z-index:-2;
}
.artTitle a::before
{
top:0;
left:0;
}
.artTitle a::after
{
top:0;
right:0;
}
.artTitle a:hover::before
{
width:50%;
}
.artTitle a:hover::after
{
width:50%;
}
效果为鼠标悬停div背景从两边向中间展现。 展开
<div class="artTitle"><a>this is a test</a></div>
css:
.artTitle
{
width:90%;
margin-top:10px;
height:45px;
font-size:20px;
padding:0 5%;
position:relative;
overflow:hidden;
}
.artTitle a::before,.artTitle a::after
{
content:" ";
position:absolute;
display:block;
width:0px;
height:45px;
background:#E3E3E3;
transition:width 0.2s linear;
-webkit-transition:width 0.2s linear;
z-index:-2;
}
.artTitle a::before
{
top:0;
left:0;
}
.artTitle a::after
{
top:0;
right:0;
}
.artTitle a:hover::before
{
width:50%;
}
.artTitle a:hover::after
{
width:50%;
}
效果为鼠标悬停div背景从两边向中间展现。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询