【发布时间】:2019-10-30 13:09:20
【问题描述】:
无法解决此问题。尝试了不同的东西,但没有任何效果。我想将文本放在图像框的正中心,但它要么出现在图像框下方,要么出现在将整个图像框向下推的位置。绝对位置是我在代码中很少使用的东西,因为我的老师很重要,但我没有找到任何其他方法来解决这个问题?
HTML
<div class="class">
<img src="http://lorempixel.com/400/200/sports/1/Dummy-Text" alt="abc jme">
<div class="texto">
<h2>goalkeepers</h2>
</div>
</div>
CSS
.class{
width:50%;
height:21vw;
float:left;
overflow: hidden;
}
.class img{
width:100%;
height:120%;
margin-top:-3.5vw;
transition: ease-in-out 0.55s;
}
.class img:hover{
-webkit-filter: blur(10px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
opacity: 1;
transform:scale(1.05);
}
.texto h2{
margin-top:0;
margin-left:0;
text-align: center;
position: relative;
}
.texto{
width:auto;
height:auto;
margin:auto;
position: absolute;
}
【问题讨论】: