2013-02-13 109 views
1

我有以下的HTML可以在查看這個fiddle:如何在使用display:table時將內部DIV填充到外部DIV的高度?

<div id="parent"> 
    <div id="a" class="grid_6" style="background-color: #ff00ff"> 
     <div class="block-border"> 
      <div style="background-color: #123456"> 
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
      </div> 
     </div> 
    </div> 
    <div id="b" class="grid_6" style="background-color: #ffff00"> 
     <div class="block-border"> 
      <div id="xx" style="background-color: red;"> 
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
      </div> 
     </div> 
    </div> 
</div> 

我怎樣才能讓這個id爲「XX」的DIV的高度,填補了含有DIV擴大?

+0

根據這個jsFiddle,沒有問題! http://jsfiddle.net/persianturtle/SLyTj/你必須有東西被覆蓋。 – 2013-02-13 21:14:15

回答

-1

如果您將.grid_6設置爲使position: relative#xx擁有height: 100%; position: absolute;它應該工作。儘管這可能並不理想。

#parent { 
    display: table-row; 
} 

.grid_6 { 
    position: relative; 
    display: table-cell; 
    width: 50%;  
} 

#xx { 
    height: 100%; 
    position: absolute; 
} 

查看此fiddle作爲一個工作示例。

+0

在IE上不起作用。 – Nit 2014-12-09 14:38:53

相關問題