Heim  >  Artikel  >  Web-Frontend  >  关于用hover鼠标经过背景图片替换闪烁的问题_html/css_WEB-ITnose

关于用hover鼠标经过背景图片替换闪烁的问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:54:491898Durchsuche

代码如下:
.mjs_download{height:260px;width:300px;float:left;border:0px solid #ffff00; background:url(../../images/mjs_landun/download.jpg) no-repeat;float:left;margin:20px 0px 0px 0px;cursor:pointer}

.mjs_download:hover {background:url(../../images/mjs_landun/download_light.jpg);cursor:pointer}

鼠标经过时会替换为另一张图片。但是每次新打开网页后第一次鼠标经过时,图片都会闪烁一次。这应该是ie没有把新图缓存到本地的原因,网上说ie6才会像这样,还给了一些加缓存的代码,但是我用的是高速浏览器,不是ie6那些老版本,不论加不加那些网上说的代码,还是闪烁。

请问什么原因呢,谢谢!


回复讨论(解决方案)

对了我想到个方法,能不能开始就先在html中加载好二张图,先设置第二张看不到,再在hover事件中把第二张设置成能看到~~~这样应该可以吧。

但是我还是想问下闪烁 的问题有没有什么方法解决。

果然 ,我再用了一个div 把新图加载在同一位置 ,然后设置style="display:none"后,不会闪烁了。

可以把两张背景图做成一张用background-position定位,这样也能解决

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn