gpt4 book ai didi

html - Bootstrap 画廊悬停

转载 作者:太空宇宙 更新时间:2023-11-04 10:05:14 24 4
gpt4 key购买 nike

我为我的画廊制作了悬停效果。画廊位于 Bootstrap 网格内。悬停本身工作正常,但在某些屏幕尺寸下,叠加层会覆盖图库图像。

有人对此问题有想法、解决方案或提示吗?

举个例子:

demo


HTML:

    <div class="container">
<div class="row">

<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>

<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>

<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>

</div>
</div>

CSS:

.box {
position: relative;
cursor: pointer;
width: 100%;
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}

.box .overbox {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100;
background-color: rgba(204, 36, 42, 0.75);
color: #fff;
opacity: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}

.box:hover .overbox {
opacity: 1;
}

.box .title {
font-size: 22px;
line-height: 131%;
font-weight: 400;
text-align: center;
padding-top: 95px;
}

@media (max-width: 991px) {
.box .title {
padding-top: 43px;
}
}

.box .tagline {
position: absolute;
bottom: 0px;
padding-top: 16px;
padding-bottom: 16px;
width: 100%;
display: flex;
justify-content: center;
font-size: 16px;
font-weight: 400;
font-style: italic;
border-top: 1px solid rgb(255, 255, 255);
}

.box_client {
position: relative;
width: 100%;
height: 100%;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}

.box_client:hover {
background: rgb(235, 234, 233);
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
-ms-filter: grayscale(0%);
-o-filter: grayscale(0%);
filter: grayscale(0%);
}

.img-responsive {
margin: 0 auto;
}

最佳答案

叠加层覆盖图库图像,因为覆盖层具有 width:100%; 并且当图像小于其容器的宽度时,叠加层覆盖图库图像,因为宽度为图片

您有 2 个选项可以使图像 width:100% 或者您可以更改 .box 类的样式并删除 width:100%; 并使其成为显示:内联 block ;

.box {
position: relative;
cursor: pointer;
// width: 100%; // remove this
display:inline-block; // add this
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}

关于html - Bootstrap 画廊悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38063509/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com