【发布时间】:2016-03-09 12:52:01
【问题描述】:
此图像显示所需的布局:
“Lorem ipsum” div 位于顶部,“Dolor sit” div 位于其下方。右“P”div 设置整个主包装部分的最小高度(第一部分),除非“Dolor sit”div 增加高度(第二部分)。
在这个 Plunker 中显示了实现: Plunker demonstration
<section id="wrapperMain" style="display:table; width:100%">
<div style="background-color:#2e3338; display: table-cell; min-width:50px; width:50px;">
<h1 style="margin-left:25%; margin-right:25%">P</h1>
</div>
<div style="background-color:dodgerblue; display: table-cell;">
<!--This section should fill its parent: dodgerblue div-->
<!--So no blue color could be seen above "Lorem ipsum" div-->
<section style="display:table; width:100%; background-color:crimson; margin-top:0;">
<div style="display:table-row">
<div style="background-color:darkslategray;">Lorem ipsum</div>
</div>
<div style="background-color: #1c1e22; border-style: none; resize: none; width: 100%;">Dolor sit Dolor sit Dolor sit Dolor sit Dolor sit Dolor sit </div>
</section>
</div>
通过设置边距、高度、显示的任意组合,我无法将第二个表格部分停靠在表格单元格内,而顶部没有边距。现在我不确定这是否是正确的方法。
【问题讨论】: