鼠标悬停时图像变暗

发布于 2024-10-21 02:34:18 字数 1279 浏览 4 评论 0原文

我有一个需要在翻转时变暗的图像列表。我真的很想在没有臃肿的 CSS 翻转技术的情况下做到这一点,因为任何时候在 Photoshop 之外度过都让我非常高兴。我已经完成了部分任务,但出了点问题。这是现场直播:

http://daveywhitney.com/dark/

代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Darken</title>
<style type="text/css">
#topnav {
    float:left;
    margin:22px 0 0 50px;
    list-style:none;
}
.kitchy {
    background-color:#000000;
    width:112px;
    height:203px;
}

#topnav  a:hover{
    opacity:.6;
}

#topnav  li {
    display:inline;
}
</style>
</head>

<body>
<ul id="topnav">
            <li class="kitchy"><a href="#"><img src="img/kitch.jpg" /></a></li>
            <li><img src="img/deck_small.jpg" /></li>
            <li><img src="img/door_small.jpg" /></li>
            <li><img src="img/lumber_small.jpg" /></li>
            <li><img src="img/tools_small.jpg" /></li>
            <li><img src="img/paint_small.jpg" /></li>
        </ul>
</body>

</html>

I have a list of images that need to darken on rollover. I would REALLY love to do this without a bloated css rollover technique as anytime spent out of photoshop makes me very happy. I got part of the way there but something is going wrong. Here it is live:

http://daveywhitney.com/dark/

CODE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Darken</title>
<style type="text/css">
#topnav {
    float:left;
    margin:22px 0 0 50px;
    list-style:none;
}
.kitchy {
    background-color:#000000;
    width:112px;
    height:203px;
}

#topnav  a:hover{
    opacity:.6;
}

#topnav  li {
    display:inline;
}
</style>
</head>

<body>
<ul id="topnav">
            <li class="kitchy"><a href="#"><img src="img/kitch.jpg" /></a></li>
            <li><img src="img/deck_small.jpg" /></li>
            <li><img src="img/door_small.jpg" /></li>
            <li><img src="img/lumber_small.jpg" /></li>
            <li><img src="img/tools_small.jpg" /></li>
            <li><img src="img/paint_small.jpg" /></li>
        </ul>
</body>

</html>

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

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

发布评论

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

评论(3

萌吟 2024-10-28 02:34:18

这是怎么回事:

JSFiddle

我更改了什么:

< ;ul>

  • 。向所有菜单项添加了 kitchy 类,
  • 更改了此 CSS:

    #topnav {
        float:left;
        margin:22px 0 0 50px;
        list-style:none;
    }
    .kitchy {
        background: #000;
        width:112px;
        height:103px;
        float:left;
        margin:5px; /*Optional*/
    }
    
    #topnav  a:hover{
        opacity:.5;
    }
    

    How is this:

    JSFiddle

    What I changed:

    <ul> and <li> to <div>. Added kitchy class to all menu items,

    Changed this CSS:

    #topnav {
        float:left;
        margin:22px 0 0 50px;
        list-style:none;
    }
    .kitchy {
        background: #000;
        width:112px;
        height:103px;
        float:left;
        margin:5px; /*Optional*/
    }
    
    #topnav  a:hover{
        opacity:.5;
    }
    
    滥情空心 2024-10-28 02:34:18

    这可能就是您正在寻找的:
    如何在鼠标悬停时使图像变暗?

    This might be what you're looking for :
    How to darken an image on mouseover?

    眼睛会笑 2024-10-28 02:34:18

    不要为 li 设置宽度、高度,也不要将其设置为内联,而是使用 float: left

    请参阅:http://jsfiddle.net/x9M2N/1/

    Dont set the width, height, for the li, and don't set it to inline, instead use float: left.

    See: http://jsfiddle.net/x9M2N/1/

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