【发布时间】:2025-12-04 13:55:01
【问题描述】:
我正在创建一个响应式网站,我试图让我的导航在悬停时更改标题背景图像,基本上,当页面打开时,图像是一条直线,当你将鼠标悬停在链接上时,一个图标出现在线上在文本上,希望它看起来像这样:
!(https://dl.dropboxusercontent.com/u/29163680/Screen%20shot%202013-10-17%20at%203.00.51%20PM.png)
我发现了一些悬停技术,但没有任何响应可以工作,任何解决方案将不胜感激!谢谢!
这是我目前的代码,不是很语义化或响应式
HTML
<body>
<a href=""
onMouseover="document.imagename.src=image2.src;" onMouseout="document.imagename.src=image1.src">PORTFOLIO</a>
<a href=""
onMouseover="document.imagename.src=image3.src" onMouseout="document.imagename.src=image1.src">ABOUT</a>
<a href=""
onMouseover="document.imagename.src=image4.src" onMouseout="document.imagename.src=image1.src">ABOUT</a>
<a href=""
onMouseover="document.imagename.src=image5.src" onMouseout="document.imagename.src=image1.src">ABOUT</a>
<img src="images/head1.png" name="imagename" border="0">
</body>
JAVASCRIPT
<SCRIPT LANGUAGE="JAVASCRIPT">
if (document.images) {
image1 = new Image
image2 = new Image
image3 = new Image
image4 = new Image
image5 = new Image
image1.src = "https://dl.dropboxusercontent.com/u/29163680/head1.png"
image2.src = "https://dl.dropboxusercontent.com/u/29163680/head2.png"
image3.src = "https://dl.dropboxusercontent.com/u/29163680/head3.png"
image4.src = "https://dl.dropboxusercontent.com/u/29163680/head4.png"
image5.src = "https://dl.dropboxusercontent.com/u/29163680/head5.png"
}
</SCRIPT>
【问题讨论】:
-
请先向我们展示您迄今为止尝试过的内容。
标签: jquery html css hover sprite