如果給出div和一系列float: left
屬性的嵌套div,如何使序列中最後一個div的右邊緣「粘」到父級的右邊緣div,只要父div的右邊緣移動,並且即使最後一個div的內容超出了可用空間,兩個邊一起移動,也是如此?將浮動div對齊到父div
+----------------------------------------+ | parent div | | +-------------+ +---------------------+| | | | | || | | div 1 | | div 2 >>||<< the right edge of div 2 | | float: left | | float: left || aligns with the right edge | | | | || of the parent div | +-------------+ +---------------------+| +----------------------------------------+
編輯:我應該提到的條件是最後一個之前的div都不允許有固定的寬度,但最後一個div的寬度應當取決於其內容和右邊緣的位置的父分部。另外,最後一個div需要左移。
http://stackoverflow.com/questions/623325/how-to-get-a-floating-div-to-fill-available-space-within-its-parent-div的可能的複製? – 2012-02-21 11:27:29