我正在制作一个Wordpress网站,有些按钮有背景图像,图像在悬停时会发生变化.这是通过简单的CSS完成的.当用户首先进入页面并将鼠标悬停在按钮上时,空间将变为空白,直到新图像加载为止.
加载所有图像以获得平滑过渡的最佳方法是什么.
PS每页最多只有2个按钮
小智 5
Make a div with an id of preload that contains all the images you want to have show up when the user hovers over the buttons and put it anywhere in your html (it doesn't matter where) ex:
<div id="preload">
<img src="path/image-01.png" width="1" height="1" alt="Image 01" />
<img src="path/image-02.png" width="1" height="1" alt="Image 02" />
<img src="path/image-03.png" width="1" height="1" alt="Image 03" />
</div>
Run Code Online (Sandbox Code Playgroud)
Then in your CSS, add:
#preload {display: none}
Run Code Online (Sandbox Code Playgroud)
this will hide your images, but they will be loaded. Just make sure that your buttons use the same path as the ones that the preload div do, or else you will be loading images twice.
Full tutorial here:
http://perishablepress.com/a-way-to-preload-images-without-javascript-that-is-so-much-better/
| 归档时间: |
|
| 查看次数: |
2964 次 |
| 最近记录: |