我有两个具有不同内容的 div
。即
<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>
但我希望它像上图那样显示。 我该怎么做?
最佳答案
这应该是您的解决方案:
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;
}
这是一个可以尝试的 fiddle :https://jsfiddle.net/sebastianbrosch/xat15tc1/1/
关于html - 如何居中对齐两个内容不同的div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32944071/