我正在創建一個網頁,並排放置2個<div>
。每個<div>
將有2個部分。 我想將它們居中(將它們帶到<div>
的中間)。我正試圖使這個<div>
響應。在網站中,2個<div>
將在一行中,而在移動中,一個<div>
將出現在一行上,而另一個<div>
將出現在第二行上。我正在嘗試將每個部分的圖像和文字居中。居中圖像和文字
我該如何做到這一點?
.wrapper {
width: 100%;
overflow: hidden;
}
.wrapper div {
min-height: 45px;
padding: 1px;
}
#one {
background-color: gray;
float: left;
width: 50%;
}
#two {
background-color: red;
overflow: hidden;
min-height: 45px;
}
@media screen and (max-width: 400px) {
#one {
float: none;
margin-right: 0;
width: auto;
border: 0;
}
}
<div class="wrapper">
<div id="one">
<img src="http://livebodybuilding.com/images/fast-delivery.png" height="26" width="55" style="float:left; margin-top: 6px;" />
<p style=" font-size:13px; color:#fff; line-height:1.5; font-family: 'Montserrat',sans-serif;"><strong> FREE DELIVERY </strong>ORDERS OVER $100</p>
</div>
<div id="two">
<img src="http://livebodybuilding.com/images/free-gift.png" height="26" width="31" style="float:left; margin-top: 6px;" />
<p style="font-size:13px; color:#fff; line-height:1.5; font-family: 'Montserrat',sans-serif;"><strong> FREE GIFT</strong> ORDERS OVER $100</p>
</div>
</div>
我的小提琴:https://jsfiddle.net/4okxw32v/
你可以看到2個師那裏..每格爲具有IMG和文字。我需要給他們帶來中心..嘗試通過使用文本對齊,垂直對齊等。文字來到中心,但IMG沒有來中心... –
是它的工作gud ..謝謝... –