CSS .Hover 图像加载缓慢
我有一个提交按钮,当用户将鼠标悬停在其上时,该按钮会发生变化。现在,图像需要一段时间才能加载,并且您会在半秒内出现白屏而不是其他按钮。有没有办法只使用 CSS 和 HTML 来改进这个,或者我需要做一些 JS 工作?
I have a submit button that changes when the user hovers his mouse over it. Right now the image is taking a while to load and you get a half second where there is white screen instead of the other button. Is there anyway to improve this using just CSS and HTML or do I need to do some JS work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用精灵图像,然后在悬停时切换背景位置。这确保悬停时显示的图像已被下载。
Use a sprite image, and then toggle background position on hover. That ensures that the image being displayed on hover has already been downloaded.
CSS Sprites
当 DOM 准备好时加载 css sprites,这可以说是“预加载”用户将鼠标悬停在提交按钮上之前的图像:)
CSS Sprites
And load the css sprites when DOM is ready, this can sort of "preload" the image before user hovers on the submit button :)