下面的代码给出了这个结果:
除了三个事实外,这与我想要的结果非常接近:
height: 100%
,但它没有工作...... 期望的结果:
div.div1 {
background-color: yellow;
border: 1px solid black;
padding: 10px;
overflow: auto;
}
div.div2 {
border: 1px solid gray;
float: right;
}
div.div3 {
background-color: orange;
border: 1px solid gray;
height: 100%;
padding: 10px;
}

<div class="div1">
<div class="div2">
<img src="http://splendidwillow.com/wp-content/uploads/2012/04/Allium-Purple-garlic-flowers-200x200.jpg">
</div>
<div class="div3">
Text about flowers
</div>
</div>
&#13;
答案 0 :(得分:1)
img
的{{1}},将其设置为0。margin-bottom
中的margin-left
和img
中的margin-right
都是5。答案 1 :(得分:1)
div.div1 {
display: flex; /* 1 */
padding: 10px;
overflow: auto;
background-color: yellow;
border: 1px solid black;
}
div.div2 {
order: 1; /* 2 */
border: 1px solid gray;
}
div.div3 {
flex: 1; /* 3 */
margin-right: 10px;
padding: 10px;
/* height: 100% */ /* 4 */
background-color: orange;
border: 1px solid gray;
}
img {
vertical-align: bottom; /* 5 */
}
&#13;
<div class="div1">
<div class="div2">
<img src="http://splendidwillow.com/wp-content/uploads/2012/04/Allium-Purple-garlic-flowers-200x200.jpg">
</div>
<div class="div3">
Text about flowers
</div>
</div>
&#13;
注意:
flex-direction: row
),其高度相等(align-items: stretch
)。order
值为0
)align-items
相等高度功能。