html - 悬停时的图像与左侧的图像重叠,但不与右侧的图像重叠

标签 html css image

我正在尝试在悬停时放大图像的大小。该图像是图库的一部分,因此左右两侧还有其他图像。问题是悬停时的图像与左侧图像重叠,但不与右侧图像重叠。

我看到了this问题相同的问题并尝试修复。它开始在 firefox 上工作,但在 Chrome 上仍然没有变化。这里有什么问题吗?

HTML

<div class="row" id="attractions">
    <div class="container" style="margin-bottom: 20px;">
        <div class="attractions-title">
            <h1 class="text-center text-danger">Gallery</h1>
        </div>
        <div class="gallery">
            <div class="gallery-item wow fadeIn hidden-xs" data-wow-delay="0.4s">
                <img src="img/attractions/adventure-cove.jpg" alt="Adventure Cove Waterpark">
                <h4 class="text-center">Adventure Cove Waterpark</h4>
            </div>
            <div class="gallery-item wow fadeIn hidden-xs" data-wow-delay="0.3s">
                <img src="img/attractions/gardens-by-the-bay-5.jpg" alt="Garden By The Bay">
                <h4 class="text-center">Garden By The Bay</h4>
            </div>
            <div class="gallery-item wow fadeIn hidden-xs" data-wow-delay="0.6s">
                <img src="img/attractions/Marina-Bay-Sands-4.jpg" alt="Marina Bay Sands">
              <h4 class="text-center">Marina Bay Sands</h4>
            </div>
        </div>
    </div>
</div>

CSS

.gallery{
    margin: 20px auto 20px auto;
}

.gallery-item{
    position:relative;
    float:left;
    margin: 15px auto 0px auto;
    width:100%;
    background:rgba(255,255,255,0.95);
    padding: 10px;
    border-radius:5px;
}

.gallery-item img{
    width:100%;
    position: relative;
    transition: all 0.5s ease;
    -webkit-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
}
.gallery-item img:hover, .gallery-item img:active{
    transform: scale(1.4);
    -ms-transform: scale(1.4);
    -o-transform: scale(1.4);
    -moz-transform: scale(1.4);
    -webkit-transform: scale(1.4);
    z-index: 10;
}

您可以在实际中看到它 here

最佳答案

z-index 解决方案添加到 .gallery-item 元素,而不是图像。

.gallery{
    margin: 20px auto 20px auto;
}

.gallery-item{
    position:relative;
    float:left;
    margin: 15px auto 0px auto;
    width:100%;
    background:rgba(255,255,255,0.95);
    padding: 10px;
    border-radius:5px;
    z-index: 9;
}

.gallery-item:hover, .gallery-item:active{
    z-index: 10;
}

.gallery-item img{
    width:100%;
    position: relative;
    transition: all 0.5s ease;
    -webkit-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
}
.gallery-item img:hover, .gallery-item img:active{
    transform: scale(1.4);
    -ms-transform: scale(1.4);
    -o-transform: scale(1.4);
    -moz-transform: scale(1.4);
    -webkit-transform: scale(1.4);
}

关于html - 悬停时的图像与左侧的图像重叠,但不与右侧的图像重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31588411/

相关文章:

javascript - 如何在(AngularJS)ui-select 组件中设置搜索输入的最大长度?

python - 使用python编辑jpg中的rgb值

Android Webview shouldOverrideUrlLoading() 不为 base64 图像数据 URL 调用

javascript - 在渲染之前使用 HTML 或 JavaScript 调整来自 URL 的图像大小

html - x-apple-data- detectors 在 href 中做什么?

javascript - 单击单选按钮时使用 PHP 启用禁用文本字段

javascript - 表头固定的JS代码TH宽度必须等于TD宽度

html - 在同一页面后台播放音频

html - 可以在 CSS 中抑制吗?

javascript - Windows 上的 CouchDB 表示请求的资源上不存在 'Access-Control-Allow-Origin' header