这是我为实现更好的解释而努力实现的形象
我正在处理的是:
You can see the live example of what I'm trying to copy for better explanation
<div class="holdmetight">
<div class="prev"><a href="/">TITLE OF PREVIOUS POST HERE</a></div>
<div class="next"><a href="/">TITLE OF NEXT POST HERE</a></div>
</div>
.holdmetight {width:100%; max-width:1023px; position:relative; display:block; }
.next, .prev { min-height:35px; height:100%; text-align:center; height:100px;}
.prev { display:block; background:#CCC; width: 100% auto; }
.next {float:left; border-right:1px solid #eceff0; background: #AAA;}
答案 0 :(得分:2)
以下是display: table
的基本布局。
display: table
的好处:
使用vertical-align: middle
两个div都根据其他内容保持相同的高度
HTML / CSS
.holdmetight {
display: table;
border: solid 1px #000;
border-top: solid 2px #000;
}
/* the > selector targets direct div children of .holdmetight */
.holdmetight > div {
display: table-cell;
vertical-align: middle;
background: #aaa;
padding: 10px;
text-align: center;
width: 50%;
}
.prev {
border-right: solid 1px #000;
}
&#13;
<div class="holdmetight">
<div class="prev">
<a href="/">
TITLE OF PREVIOUS POST HERE.
This is a particulary long title
that will push both divs down.
</a>
</div>
<div class="next">
<a href="/">
TITLE OF NEXT POST HERE
</a>
</div>
</div>
&#13;
答案 1 :(得分:0)
.holdmetight {width:100%; max-width:1023px; position:relative; display:block; }
.next, .prev { min-height:35px; height:100%; text-align:center; height:100px; display:inline-block;}
.prev { background:#CCC; width: 100% auto; }
.next { border-right:1px solid #eceff0; background: #AAA;}
根据需要添加填充