【发布时间】:2020-04-30 08:37:37
【问题描述】:
我有一个图片库,您可以在其中通过“鼠标进入”同一页面上显示的缩略图来更改显示的图像。 现在我想向画廊添加一个视频,但它不适用于我为图像提供的代码。 问题是我希望图片和视频保持一定的大小。由于我想添加视频,所以 img 标签不会将视频显示为源,当我将 img 更改为 iframe 时,视频效果很好,但图片不再响应。这是我的代码:
HTML
<div class="slide_work">
<img src="images/Illustration/puzzled.png">
</div>
<div class="slide_thumbs">
<div id ="thumbs_active" class="puzzled_img" style="background-image:url(images/Illustration/puzzled_img.png);"></div>
<div class="puzzled_vid" style="background-image:url(images/Illustration/puzzled_vid.png);"></div>
CSS
.slide_work > img {
float:right;
height:auto;
width:auto;
max-height:70vh;
max-width:100%;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
(我尝试在 CSS 中添加另一个块,将“img”更改为“iframe”,但它对图像的响应性没有任何作用。)
JavaScript
$( ".puzzled_img" )
.mouseenter(function() {
$(".puzzled").attr('src', 'images/Illustration/puzzled.png');
$(this).attr('id', 'thumbs_active');
$(".puzzled_vid").removeAttr('id', 'thumbs_active');
})
$( ".puzzled_vid" )
.mouseenter(function() {
$(".puzzled").attr('src', 'https://player.vimeo.com/video/12345678');
$(this).attr('id', 'thumbs_active');
$(".puzzled_img").removeAttr('id', 'thumbs_active');
})
【问题讨论】:
-
如果您提供minimum reproducible code 来查看问题,那就太好了。
标签: javascript html css iframe responsive