我有一个固定的标题。当我滚动时,某些元素会覆盖标题。我该如何防止这种情况?
我可以立即想到两个解决方案。您可以给#headercontainer元素az 索引 CSS 属性 http://www.w3schools.com/Css/pr_pos_z-index.asp...
#headercontainer
#headercontainer { /* ... other CSS ... */ z-index: 1000; }
...或者你可以按照我认为应该做的方式来做...
#headercontainer { /* ... other CSS ... */ position: fixed; top: 0px; } #contentcontainer { /* ... other CSS ... */ margin-top: 125px; /* this should be at least the height of the header */ }
在第二个解决方案中,您不必担心哪个元素悬停在哪个其他元素上。这#contentcontainer元素被正确地推到下面#headercontainer元素,使它们没有重叠。
#contentcontainer