我有一個頁面,我想要一個元素在同一時間對齊,我有可能是寬的元素,並導致水平滾動條。例如:正確對齊元素,同時存在一個水平滾動條
<body>
<div style="float:right">Stay right</div>
<div style="white-space:nowrap; clear:both; font-size:2em">
Wide child element which determines the width of the page.
</div>
</body>
如果寬元素適合瀏覽器窗口,此工作正常。但是,如果瀏覽器窗口過小,以致出現horisontal滾動條「留權」元素將與窗口對齊,而不是頁面:
如果我移動滾動條「留權」元素移動,並沒有真正對齊任何東西。
如果添加整個頁面圍着一張桌子它做什麼,我wan't:
<body>
<table width="100%"><tr><td>
<div style="float:right">Stay right</div>
<div style="white-space:nowrap; clear:both; font-size:2em">
Wide child element which determines the width of the page.
</div>
</td></tr></table>
</body>
的「留權」的元素將與廣子元素的右側對齊瀏覽器窗口大小無關。
編輯:上面的表基於溶液將右對齊到最大的寬子元素或窗口寬度的寬度。實際上,這給頁面提供了一個由頁面內容決定的「最小寬度」(即寬子元素)。這是我想要的 - 從原文中不清楚,對不起。
我想知道是否有比包裝整個頁面更好的方法。
據我所見,此解決方案不能解決問題。 myDivThatFloatsRight不會考慮寬子元素的寬度。 – 2012-11-12 11:44:02