我爲一個項目使用引導框架,但我遇到了一箇中心的div爲我的網站的麻煩。引導垂直div全背景
我需要把一個div垂直居中,但背景色爲100%全寬,並在引導的容器div內。
我需要建立圖像的藍色部分(中央DIV)http://www.hmsg.net/layout.png
我爲一個項目使用引導框架,但我遇到了一箇中心的div爲我的網站的麻煩。引導垂直div全背景
我需要把一個div垂直居中,但背景色爲100%全寬,並在引導的容器div內。
我需要建立圖像的藍色部分(中央DIV)http://www.hmsg.net/layout.png
試試這個
<div class="col-lg-12"
style="padding:0px; background-image: url('http://www.kiteworldmag.com/media/wallpapers/2/187/3.jpg'); background-size: 100% auto; height:500px;;">
<div class="col-lg-12" style="height:300px; padding:0px; margin:0px; display: block">
</div>
<div class="col-lg-12" style="background-color:#ffffff; height:100px; padding:0px; margin:0px;">
sdfsdf
</div>
</div>
使用本
<div class="col-lg-12" style="background: url("../img/Bg.png"); background-size: 100% auto; height:100%;">
<div class="col-lg-12" style="hieght:500px; padding:0px; margin:0px;">
</div>
<div class="col-lg-12" style="background-color:#ffffff; hieght:500px; padding:0px; margin:0px;">
</div>
</div>
感謝Harutyun,你的答案,
我用這個解決方案結束了:
<div style="margin:0; padding:0px; width:100%; height:100%; display:table">
<div style="display: table-cell; vertical-align: middle;" >
<div style="background:#99FF33">
<div class="container">Content Goes Here.</div>
</div>
</div>
</div>
嗨Harutyun, 我覺得你的例子不適合我。 我想做這樣的事情http://www.hmsg.net/layout_example.jpg。我的問題是中間div,我不能把它垂直居中,並有100%的背景寬度。 – 2014-09-30 15:31:49
我更改代碼請參閱並嘗試此操作 – 2014-09-30 16:05:19