[英]How to center align two divs with different content?
我有兩個div
具有不同的content.ie
<div class="container-fluid" style="background-color:#2c5fd9;"> <div class="row" style="padding:10px 0;"> <div class="col-lg-1" style="display:table-cell;vertical-align:middle;border-right:1px solid #fff;"> <div style="width:100%;color:#fff;">-</div> </div> <div class="col-lg-10" style="display:table-cell;vertical-align:middle;padding:0 10px;"> <h1>The three big ideas we hope you take away</h1> </div> </div> </div>
但我希望它像上面的圖像一樣顯示。 我怎樣才能做到這一點?
這是更新代碼,對我來說效果很好,希望它能解決您的問題。
<div class="container-fluid" style="background-color:#2c5fd9;">
<div class="row" style="padding:10px 0; display:table; width:auto; margin:0px auto">
<div class="col-lg-1" style="display:table-cell;vertical-align:middle;border-right:1px solid #fff;">
<div style="width:100%;color:#fff;">-</div>
</div>
<div class="col-lg-10" style="display:table-cell;vertical-align:middle;padding:0 10px;">
<h1 style="width:85%">The three big ideas we hope you take away</h1>
</div>
</div>
</div>
這應該是您的解決方案:
的HTML
<div class="container-fluid custom-box">
<div class="row">
<div class="col-lg-1 line">
<div class="hr"></div>
</div>
<div class="col-lg-10 content">
<h1>The three big ideas we hope you take away</h1>
</div>
</div>
</div>
的CSS
.custom-box {
background-color:#00577b;
padding:30px 0;
width:700px;
}
.custom-box .line {
border-right:1px solid #fff;
display:table-cell;
padding:0;
vertical-align:middle;
}
.custom-box .content {
display:table-cell;
padding:10px 40px;
vertical-align:middle;
}
.custom-box .content h1 {
color:#fff;
padding:0;
margin:0;
}
.hr {
border-top:1px solid #fff;
height:1px;
width:75px;
}
這是嘗試的小提琴: https : //jsfiddle.net/sebastianbrosch/xat15tc1/1/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.