我有這個代碼,但.text
不能按我的預期工作。 auto
應該適合容器的width
,但.text
div將被推到第二行。我需要自動值,因爲圖像的寬度可以改變,並且無論圖像寬度如何,正確的div都應該放在容器中。自動調整div的大小
<div class="container">
<div class="img"><img src="http://placehold.it/350x150"></div>
<div class="text">Some text Some textSome textSome textSome textSome textSome textSome textSome textSome textSome textSome textSome textSome textSome text</div>
</div>
.img, .text {
float:left;
}
.text{
border: 1px solid red;
height:150px;
width:auto; //should be width:248px in this specific case;
}
.container{
width:600px;
border:1px solid green;
height:150px
}
你有沒有嘗試過填充和繪製邊界旁邊IMG沒有溢出(或其他修改佈局的修改規則)嗎?http://jsfiddle.net/LCAKw/12/ –