答案 0 :(得分:4)
试试这个:
<div class="con">
<div id="div3"></div>
<div id="div1_2">
<div id="div1"></div>
<div id="div2"></div>
</div>
</div>
#div3{height:100px;width:100px;border: solid 1px #000; display:inline-block; background:red;}
#div1{height:30px;width:100px;border: solid 1px #000; position:absolute; top:0; background:blue;}
#div2{height:20px;width:100px;border: solid 1px #000; position:absolute; bottom:0; background:green;}
#div1_2{display:inline-block; vertical-align:top;}
.con { position:relative; }
答案 1 :(得分:2)
这有效:
#div3{height:100px;width:100px;border: solid 1px #000;
display:inline-block;}
#div1{height:30px;width:100px;border: solid 1px #000;}
#div2{height:20px;width:100px;border: solid 1px #000; position: absolute; bottom: 0}
#div1_2{display:inline-block;vertical-align:top; position: relative; height: 100px;}
答案 2 :(得分:1)
答案 3 :(得分:1)
我建议您使用绝对位置进行此基本定位:
<div id="content">
<div id="div3"></div>
<div id="div1"></div>
<div id="div2"></div>
</div>
#content { position: relative; height: 100px; width: 220px; }
#div1{ position: absolute; top: 0; right: 0; height:30px; width:100px; background: blue; }
#div2{ position: absolute; bottom:0; right: 0; height:20px; width:100px; background: green; }
#div3{ position: absolute; top: 0; left: 0; height:100px; width:100px; background: red; }
答案 4 :(得分:0)
<div style="position: relative;">
<div style="height: 100%;"> </div>
<div style="position: absolute; right: 0px;"> </div>
<div style="position: absolute; right: 0px; bottom: 0px;"> </div>
</div>
通过使外部div'相对',您可以使用绝对比例将其他div放在里面。将第二个对齐到右侧,将最后一个对齐到右侧和底部。您可能需要根据需要为样式添加高度/最小高度。