使用
position: fixed的
div包含您的头,喜欢的东西
#header { position: fixed;}#content { margin-top: 100px;}在此示例中,当
#content开始时位于下方100px处
#header,但随着用户滚动,它
#header保持原位。当然,不用说,您需要确保
#header有背景,以便当两个
divs重叠时,其内容实际上是可见的。

使用
position: fixed的
div包含您的头,喜欢的东西
#header { position: fixed;}#content { margin-top: 100px;}在此示例中,当
#content开始时位于下方100px处
#header,但随着用户滚动,它
#header保持原位。当然,不用说,您需要确保
#header有背景,以便当两个
divs重叠时,其内容实际上是可见的。