如何獲得固定的位置,並且不會疊加在另一個div的頂部?在CSS中的固定位置和覆蓋位置
例如:
<html>
<body>
<div style="background-color:black; height:200px;">
</div>
<div style="background-color:blue; height:400px;">
</div>
</body>
</html>
我要的是頂級的div總是在頂部,但不要擋住底部的DIV的任何部分。例如:http://twitter.github.com/bootstrap/
頂部的黑色菜單始終保留在頂部,而不會遮擋任何其他div的視圖。我檢查了該網站上的topbar css,並將其插入到我自己的測試文檔中,但無法達到預期的效果。除了「position:fixed」之外,我還需要做些什麼?
正確。在發佈的鏈接`header .inner`中有一個45px的頂部填充。 – ptriek 2011-12-15 21:25:43