image - 悬停链接以更改图像的不透明度

标签 image hyperlink hover opacity

我正在尝试获得此处显示的效果https://www.kogevitamins.com/

您将鼠标悬停在“了解更多”链接上以使图像的不透明度也发生变化。

谢谢。

编辑:

我现在有

HTML

    <img src="/images/pill.png" alt="description" id ="image" />
<p> Daily Essentials </p>
<a id ="button"  href="#">Learn More</a>

对于jquery

    $("#button").hover(function(){
    $("#image").animate({opacity:1},300);
}).mouseout(function(){
    $("#image").animate({opacity:0.6},300);;
});

目前看来还不行

编辑:

我最近更新了以下代码,但悬停效果对我不起作用。这是我要开始工作的链接 http://maninkorean.com/

<div class ="product-content">
<img class="imgClass" src="/images/pill.png" alt="description"  />
<p> Daily Essentials </p>
<a id ="button"  href="#">Learn More</a>
</div>

 $("a#button, img").hover(function(){
    $("img.imgClass").animate({opacity:1},300);
}).mouseout(function(){
    $("img.imgClass").animate({opacity:0.6},300);;
});

img.imgClass{
    opacity: 0.6
}

#button {
    padding: 10px 24px;
    background:#F15951;
    border: medium none;
    border-radius: 3px 3px 3px 3px;
    color:white;
    margin-top:50px;
    margin-bottom:50px;
    font-weight: bold;
}

最佳答案

您应该能够使用 jQuery 和以下代码来做到这一点:

$('#id of link you want to use to change opacity').hover(function() { $('#id of image that you want to change opacity of').css({ 'opacity' : 0.25 }); });

关于image - 悬停链接以更改图像的不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17351395/

相关文章:

html - CSS 在悬停时显示 div

image - Xamarin 形成可点击的图像

具有超链接特征的 HTML 按钮

php - 创建随机 url 链接

jquery - 用户点击图片,视频开始播放

css - 将标题悬停在图像上会导致图像下方出现大的白色间隙

html - 如何使用 :hover? 在文本后面显示图像

javascript - 如何在 img 标签的 src 属性中包含一个随机数变量

java - 计算图像重叠百分比

html - 从 CSS 文件更改 Logo 图像?