jquery - 悬停时更改多个图像 : jquery/css/html

标签 jquery html css

这就是我想要做的。我有一张缩略图表格,表格中间有一张大图。

img01 |  img02 | img03 | img04

img05 | `*BIG IMAGE *` | img06

img07 | `*BIG IMAGE *` | img08

img09 | `*BIG IMAGE *` | img10

img11 | `*BIG IMAGE *` | img12

img13 |  img14 | img15 | img16

当您将鼠标悬停在缩略图上时:

1) 缩略图的不透明度从 50% 变为 100% 并且
2) BIG IMAGE 将更改为 img01 的 400x400 图片(即 img01_400x400.jpg)

当您同时单击缩略图时,“大图像”将变为 400x400 图像

我能够让编码正常工作到步骤 (1),其中缩略图的不透明度在悬停时发生变化。

有谁知道如何完成第 (2) 步?非常感谢任何帮助。 我已经坚持了几天。

迈克

添加评论中的代码片段

这是我目前为止的 css:

.hovereffect img { opacity:0.5; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5; } 
.hovereffect:hover img { opacity:1.0; filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100); -moz-opacity:1.0; -khtml-opacity:1; }

这是其中一个缩略图的一段代码片段:

<td align="center">
    <a class="hovereffect" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="/ad01.php"><img style="cursor: pointer; width: 66px; height: 66px;" src="/images/ad_01d.png" alt="Hover Effect" id="" border="0" /></a>
</td>

最佳答案

这是一个很好的淡入淡出效果。它淡出背景图像之上的图像。希望它可以帮助您入门。

http://jsfiddle.net/Diodeus/gYyBL/

HTML:

<img src="http://i.imgur.com/vdDQgb.jpg" hoverImg="http://i.imgur.com/Epl4db.jpg" bigImg="http://i.imgur.com/Epl4db.jpg">
<img src="" style"display:none" id="big"> 

JS:

$('body').find('*[hoverImg]').each(function(index){
    $this = $(this);
    $this.wrap('<div>')  ;   
    $this.parent().css('width',$this.width()) ; 
    $this.parent().css('height',$this.width());
    $('#big').attr('src',$this.attr('hoverImg')); <-- this will show the big image;
    $this.parent().css('background-image',"url(" + $this.attr('hoverImg')+")")
        $this.hover(function() {
            $(this).stop()
            $(this).fadeTo('',.01)    
        },function() {
            $(this).stop()
            $(this).fadeTo('',1)             
        })                    
});

关于jquery - 悬停时更改多个图像 : jquery/css/html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12696717/

相关文章:

jquery - 如果浏览器是 Internet Explorer,加载不同的 jquery 脚本?

javascript - Angular Material 和 md-nav-bar 路由

javascript - 将 Audio 对象设置为未定义是否会导致内存泄漏?

css - css 文件中的属性或变量

css - 如何使中间列 div 始终扩展以适合?

javascript - 我如何制作一个图像 url 数组,将它们附加到现有数组,并让页面使用 jQuery 加载图像?

javascript - 有效的隐藏和表演类(class)

javascript - 如果选中所有复选框,则启用 JQuery 按钮并将 css 添加到禁用按钮

jquery - 拖放到可滚动的 div 上

javascript - 在此上下文中只允许返回数字或 bool 值的变量表达式