利用CSS transform屬性中的 translateY 來改變垂直位移
再利用position:relative 設定 top屬性,配合使物件可以垂直置中
<div class="col-xs-4 recommendPic">
<img src="/template/hw/pic/obj2243009_1.jpg" >
</div>
<style>
.recommendPic{
padding: 0px;
background-color: #ebebeb;
width: 33.3333%;
height: 126px;
text-align: center;
}
.recommendPic>img {
max-height: 126px;
max-width: 100%;
position: relative;
top: 50%;
transform: translateY(-50%);
}
</style>
全站熱搜
留言列表