HTML结构
<div id="small_gal"> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> <div><img src="images1.jpg" /></div> </div>
这些图像有阴影,所以边框不是一个解决方案,因为它将在图像之外
边界已经过渡,它在FF上平稳运行,但不能在chrome或其他浏览器中运行
这是我使用的代码
#small_gal div:hover{cursor: pointer;} #small_gal div:after { content: ''; position: absolute; width: 112px; height: 81px; border: 3px solid #e27501; left: 9px; top: 9px; z-index: 9; opacity: 0; -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; -ms-transition: opacity 0.5s ease-in-out; transition: opacity 0.5s ease-in-out; } #small_gal div:hover:after { opacity: 1; }
注意:
#small_gal
只是容器
每个图像被包裹在一个div中,所以我们可以实现:after
解决方法
Firefox 4是唯一支持伪元素过渡的浏览器,如:before和after.
资料来源:http://css-tricks.com/13555-transitions-and-animations-on-css-generated-content/