gpt4 book ai didi

html - 响应式图像悬停标题

转载 作者:行者123 更新时间:2023-11-28 01:03:06 25 4
gpt4 key购买 nike

我面临的问题是悬停标题 .caption-text 和叠加层 .blur 的宽度和高度是固定的,而图像是响应式的。

关于如何修改此代码以使叠加层和标题适合图像宽度和高度的任何建议?

.caption-style-4 {
list-style-type: none;
margin: 0px;
padding: 0px;
}
.caption-style-4 li {
float: left;
padding: 0px;
position: relative;
overflow: hidden;
}
.caption-style-4 li:hover .caption {
opacity: 1;
}
.caption-style-4 li:hover img {
opacity: 1;
transform: scale(1.15, 1.15);
-webkit-transform: scale(1.15, 1.15);
-moz-transform: scale(1.15, 1.15);
-ms-transform: scale(1.15, 1.15);
-o-transform: scale(1.15, 1.15);
}
.caption-style-4 img {
margin: 0px;
padding: 0px;
float: left;
z-index: 4;
}
.caption-style-4 .caption {
cursor: pointer;
position: absolute;
opacity: 0;
-webkit-transition: all 0.45s ease-in-out;
-moz-transition: all 0.45s ease-in-out;
-o-transition: all 0.45s ease-in-out;
-ms-transition: all 0.45s ease-in-out;
transition: all 0.45s ease-in-out;
}
.caption-style-4 img {
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
-ms-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
}
.caption-style-4 .blur {
background-color: rgba(0, 0, 0, 0.65);
height: 300px;
width: 400px;
z-index: 5;
position: absolute;
}
.caption-style-4 .caption-text h1 {
text-transform: uppercase;
font-size: 24px;
}
.caption-style-4 .caption-text {
z-index: 10;
color: #fff;
position: absolute;
width: 400px;
height: 300px;
text-align: center;
top: 100px;
}
<div class="container-a4">
<ul class="caption-style-4">
<li>
<img src="http://lorempixel.com/output/abstract-q-c-600-480-1.jpg" alt="">
<div class="caption">
<div class="blur"></div>
<div class="caption-text">
<h1>Amazing Caption</h1>
<p>Whatever It Is - Always Awesome</p>
</div>
</div>
</li>
</ul </div>

http://codepen.io/anon/pen/GNzMNV

最佳答案

只需更新你的CSS

.caption-style-4 .caption-text {
z-index: 10;
color: #fff;
position: absolute;
width: 100%;
height: 95px;
text-align: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.caption-style-4 .blur {
background-color: rgba(0,0,0,0.65);
height: 100%;
width: 100%;
z-index: 5;
position: absolute;
}
.caption-style-4 .caption {
cursor: pointer;
position: absolute;
opacity: 0;
-webkit-transition: all 0.45s ease-in-out;
-moz-transition: all 0.45s ease-in-out;
-o-transition: all 0.45s ease-in-out;
-ms-transition: all 0.45s ease-in-out;
transition: all 0.45s ease-in-out;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
}

这是更新的codepen http://codepen.io/anon/pen/MbLEXr

如果仍然无法正常工作,请告诉我。

关于html - 响应式图像悬停标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41220422/

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