当我使用CSS将鼠标悬停在某些文本上时,我正在尝试使用淡入淡出的图像.我已经应用了CSS代码,但效果没有显示出来; div出现了,但没有淡入.
此外,我意识到CSS转换并不真正适用于IE.如果有人能指出我的解决方法的正确方向,那将非常感激. (:
CSS:
.thumbnail{ position: relative; z-index: 0; } .thumbnail:hover{ background-color: transparent; z-index: 50; } .thumbnail span{ /*CSS for enlarged image*/ position: relative; display: none; color: black; text-decoration: none; opacity:0.0; filter:alpha(opacity=0); } .thumbnail span img{ /*CSS for enlarged image*/ border-width: 0; padding: 5px; left: -1000px; border: 1px solid gray; background-color: #fff; } .thumbnail:hover span{ /*CSS for enlarged image on hover*/ position: relative; display: inline; top: -290px; left: -25px; opacity:1.0; filter:alpha(opacity=100);/*position where enlarged image should offset horizontally */ -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } #networking { width: 200px; height: 140px; margin-left: 360px; top: 115px; position: absolute; background-color: #613286; opacity:1.0; filter:alpha(opacity=100); color: #ffffff; text-align:center; border-radius: 20px; -webkit-transform: rotate(14deg); -moz-transform: rotate(14deg); -ms-transform: rotate(14deg); -o-transform: rotate(14deg); transform: rotate(14deg); }
HTML:
<div id="networking"> <a class="thumbnail" href="1.5.2experientialstudios.html#down4"><h4>Networking Lounge</h4> <span><img src="images/net3.jpg" width="250" /></span></a> </div>
谢谢!
解决方法
尝试删除显示规则:
.thumbnail span{ /*CSS for enlarged image*/ position: relative; /*display: none; remove this */ color: black; text-decoration: none; opacity:0.0; filter:alpha(opacity=0); }
由于你有不透明度0,你不需要显示:无,你不能在完全不显示之间进行转换,因为它们是不同的类型.
并修改此规则:
.thumbnail:hover span { /*CSS for enlarged image on hover*/ top: 0px; /* adjust as needed */ left: -25px; opacity:1.0; filter:alpha(opacity=100);/*position where enlarged image should offset horizontally */ -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; -o-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; }
(悬停然后跨度可以使它有点跳跃).
我还为转换添加了ms前缀版本.在这种情况下,它显然没有用处.
对于IE9及更低版本,您可以使用jQuery淡入元素(或者只是使用vanilla JavaScript来修改setTimeout循环中的不透明度).
小提琴:
http://jsfiddle.net/AbdiasSoftware/9rCQv/
这就是你要追求的吗?