如何使我的图像悬停?

发布于 2024-12-19 15:00:33 字数 680 浏览 4 评论 0原文

我试图让我的徽标悬停在鼠标悬停上,但它不起作用。我有两张图片上传到我的服务器。这是代码,她是网址。有什么问题吗?

http://arabic001.com

<div id='logo'>
            <a href="/index.html">
                <img src="/images/logo001H.png" style="display:none">
                <img src="/images/logo001.png"
                    onMouseOver="this.src='/images/logo001H.png'" 
                    onMouseOut="this.src='/images/logo001.png'">
            </a>
        </div>
#logo {
    position:absolute;  
    text-align:center;
    top:20px;
    right:10px;
    height:150px;
    width:150px;
    cursor:pointer;
}

I am trying to make my logo hover on mouseover and it is not working. I have two images uploaded to my server. Here is the code and her is the url.What is wrong?

http://arabic001.com

<div id='logo'>
            <a href="/index.html">
                <img src="/images/logo001H.png" style="display:none">
                <img src="/images/logo001.png"
                    onMouseOver="this.src='/images/logo001H.png'" 
                    onMouseOut="this.src='/images/logo001.png'">
            </a>
        </div>
#logo {
    position:absolute;  
    text-align:center;
    top:20px;
    right:10px;
    height:150px;
    width:150px;
    cursor:pointer;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧伤慢歌 2024-12-26 15:00:33

我不是 Javascript 专家,但我不会为此使用 Javascript。

尝试以下 CSS:

a.logo { /* and add class="logo" to the a-element */
    display:block;
    width:150;
    height:105px;
    background:url(/images/logo001H.png) no-repeat;
}    
a.logo:hover {
    background:url(/images/logo001.png) no-repeat;
}

并删除 img 的...

I'm not a Javascript expert, but I wouldn't use Javascript for this.

Try the following CSS:

a.logo { /* and add class="logo" to the a-element */
    display:block;
    width:150;
    height:105px;
    background:url(/images/logo001H.png) no-repeat;
}    
a.logo:hover {
    background:url(/images/logo001.png) no-repeat;
}

And remove the img's...

池予 2024-12-26 15:00:33

我建议你使用 css sprites。

http://css-tricks.com/158-css-sprites/

你的html代码将如下所示:

<div id='logo'>
    <a href="/index.html"></a>
</div>

和 css 代码:

#logo a{ 
    text-align:center;
    top:20px;
    right:10px;
    height:150px;
    width:150px;
    cursor:pointer;

    background: url(/images/logo.png) no-repeat;
    display: block;
}
#logo a:hover{
    background-position: 0 -150px;
}

您的最终图像将包含两个图像:默认图像和悬停图像。

I propose you use css sprites.

http://css-tricks.com/158-css-sprites/

Your html code will look something like this:

<div id='logo'>
    <a href="/index.html"></a>
</div>

And css code:

#logo a{ 
    text-align:center;
    top:20px;
    right:10px;
    height:150px;
    width:150px;
    cursor:pointer;

    background: url(/images/logo.png) no-repeat;
    display: block;
}
#logo a:hover{
    background-position: 0 -150px;
}

Your final image will contain both images: default and hover.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文