我試圖讓父div只與子div一樣寬。自動寬度使父div適合整個屏幕。子div的寬度取決於它們的內容,所以我需要父div來做相應的調整。謝謝你的幫助!如何使一個父div自動調整到其子div的寬度
<div style='width:auto;'>
<div style="width: 135px; float: left;">
<h4 style="padding-right: 5px; padding-left: 15px;">Column1</h4>
<dl style="padding-right: 5px; padding-left: 15px; margin-top: -8px; overflow-x: hidden;">
<dd style="white-space: nowrap;">1</dd>
<dd style="white-space: nowrap;">2</dd>
</dl>
<h4 style="padding-right: 5px; padding-left: 15px;">Column1</h4>
<dl style="padding-right: 5px; padding-left: 15px; margin-top: -8px; overflow-x: hidden;">
<dd style="white-space: nowrap;">1</dd>
<dd style="white-space: nowrap;">2</dd>
</dl>
</div>
<div style="width: 135px; float: right;">
<h4 style="padding-right: 5px; padding-left: 10px;">Column2</h4>
<dl style="padding-right: 5px; padding-left: 15px; margin-top: -8px; overflow-x: hidden;">
<dd style="white-space: nowrap;">1</dd>
<dd style="white-space: nowrap;">2</dd>
<dd style="white-space: nowrap;">3</dd>
</dl>
</div>
</div>
感謝Madbreaks。製作左側花車是我沒有嘗試的。 – bradley4 2013-02-27 01:19:15
當然可以。如果你覺得我幫了你的忙,請考慮提高我的答案,或者如果你覺得這是正確的,請接受它。 – Madbreaks 2013-02-27 01:21:03
我需要等5分鐘才能接受它=) – bradley4 2013-02-27 01:23:02