2014-09-26 45 views
0

延伸100%I使用自舉3.我有以下的HTML(的jsfiddle:http://jsfiddle.net/mddc/6ntwb431/5/CSS:如何使顯示一個DIV:表小區1在寬度

<div class="container"> 
    <div class="row" style="background-color: yellow"> 
     <div class="alert">This is alert!</div> 
    </div> 
</div> 

和CSS:

.alert { 
    height: 40px; 
    display: table-cell; 
    background-color: red; 
    vertical-align: middle; 
    text-align: center; 
} 

我希望.alert DIV在其包含的DIV內寬度擴展100%,但無法弄清楚如何經過多次測試。

謝謝!

回答

2

您應該將「表格單元格」包裝在表格中。因此,在這種情況下,你將以下添加到該行類

.row{ 
    display:table; 
    width:100%; 
} 
相關問題