我需要一些關於此問題的建議。在下面的jsfiddle
中,我試圖創建一個響應式grid
佈局。我所擁有的問題是,我希望文本位於每個人的中間grid
。我已經嘗試使用margin-top來碰撞它,但是在調整大小時不是將圖像堆疊到彼此上,而是圖像彼此重疊。所需的最終結果是使文本在圖像上居中對齊,並在根據各種屏幕分辨率調整大小時在grid
的所有側面沒有間隙。響應式內嵌塊查詢
鏈接:http://jsfiddle.net/kelvinchow/VaDS9/
<style type="text/css">
#wrapper {
display: block;
width: 100%;
height: auto;
background: green;
}
.box {
display: inline-block;
float: left;
width: 50%;
height: auto;
vertical-align: baseline;
background: red;
}
.box-img img {
width: 100% !important;
height: auto;
}
.box-title {
display: block;
background: grey;
height: 25px;
font-size: 20px;
font-family: helvetica, san serif;
color: blue;
text-align: center;
margin-top: -100px;
}
</style>
<div id="wrapper">
<div class="box">
<div class="box-img">
<img src="http://airinlee.com/wp-content/uploads/2013/06/thumbnail6.png">
</div>
<p class="box-title">howdy</p>
</div>
<div class="box">
<div class="box-img">
<img src="http://airinlee.com/wp-content/uploads/2013/06/thumbnail6.png">
</div>
<p class="box-title">howdy</p>
</div>
<div class="box">
<div class="box-img">
<img src="http://airinlee.com/wp-content/uploads/2013/06/thumbnail6.png">
</div>
<p class="box-title">howdy</p>
</div>
<div class="box">
<div class="box-img">
<img src="http://airinlee.com/wp-content/uploads/2013/06/thumbnail6.png">
</div>
<p class="box-title">howdy</p>
</div>
</div>
這樣的事情? http://jsfiddle.net/peteng/VaDS9/1/ – Pete