CSS :after hover Transition(CSS:悬停后过渡)
问题描述
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>
图像有阴影,所以 border
不是解决方案,因为它会在图像之外
The images are having dropshadows so border
is not a solution, as it will be outside the image
边框有过渡,在 FF 上可以流畅运行,但在 chrome 或其他浏览器中不行
The border is having transition and it works smoothly on FF but not in chrome or other browsers
这是我使用的代码
#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
is only the container each image is wrapped in a div so we can implement :after
推荐答案
Firefox 4+ 是唯一支持 :before
和 :after<等伪元素过渡的浏览器/代码>.
Firefox 4+ is the only browser that supports the transitioning of pseudo-elements such as :before
and :after
.
来源:http://css-tricks.com/13555-transitions-and-animations-on-css-generated-content/
这篇关于CSS:悬停后过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS:悬停后过渡
基础教程推荐
- 当用户滚动离开时如何暂停 youtube 嵌入 2022-01-01
- 有没有办法使用OpenLayers更改OpenStreetMap中某些要素 2022-09-06
- 悬停时滑动输入并停留几秒钟 2022-01-01
- 响应更改 div 大小保持纵横比 2022-01-01
- 我什么时候应该在导入时使用方括号 2022-01-01
- 在 JS 中获取客户端时区(不是 GMT 偏移量) 2022-01-01
- 角度Apollo设置WatchQuery结果为可用变量 2022-01-01
- 动态更新多个选择框 2022-01-01
- Karma-Jasmine:如何正确监视 Modal? 2022-01-01
- 在for循环中使用setTimeout 2022-01-01