HTML
<div class="feature" >
<img src="0308_WVenvirophotos1-water-pollutions.jpg"
width="100%" height="100%"/></div>
CSS
.feature{
height:50%;
width: 60%;
float: left;
margin: 0.5%;
-webkit-transition: width 1s, height 1s, -webkit-transform 2s;
transition: width 1s, height 1s, transform 2s;
}
.feature:hover{
width: 800px;
height: 520px;
-webkit-transform: translate(,) ;
transform: translate(,);
}
此代码在悬停时使图片变大。如何让文本也出现在悬停时?
最佳答案
使用伪元素:before ,你可以这样做:
.feature:hover:before {
content:'Text Goes Here';
font-size:20px;
color:white;
position:absolute;
top:0;
left:0;
}
本质上,我们通过使用 :before 的 content 属性将文本添加到悬停时的元素。
在此处查看 fiddle :http://jsfiddle.net/34p5xqmL/
关于html - 悬停已经悬停转换的图片时,如何使文本出现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28890561/