【发布时间】:2015-01-29 18:41:26
【问题描述】:
我试图在悬停居中显示缩略图标题:水平和垂直对齐,但不成功。
在小提琴中,您会看到一个响应式缩略图网格,悬停时带有标题。我给了它一个红色的虚线边框,所以你可以看到它与缩略图的大小不同。我无法让标题标题在缩略图中居中。也许我的缩略图网格需要不同的构建。希望有人可以帮助我。
#content {
position: relative;
display: inline-block;
margin: 110px 40px 100px 40px;
background-color: transparent;
}
.col-25 {
position: relative;
float: left;
width: 25%;
margin: 0;
}
.thumb {
display: block;
margin: 10px;
}
.col-25 img {
width: 100%;
height: auto;
}
.col-25 a:hover img {
opacity: 0.1;
}
.caption {
position: absolute;
top:0;
left:0;
border: dashed 1px red;
width:100%;
height:100%;
opacity: 0;
text-align:center;
vertical-align: middle;
z-index:2;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
}
.col-25 a:hover .caption {
opacity: 1;
}
【问题讨论】: