这里是代码片段。我正在开发一个杂货清单的web应用,我想把顶部div设为固定位置。但是,这样做会导致该div与页面的其他部分重叠。我尝试在CSS中使用两个不同的position属性(
position: relative; position: fixed
),但这并不能使div保持固定。#top {
width: 100%;
height: 40px;
background: #96f226;
text-align: center;
font-size: 30px;
color: #252525;
position: relative;
position: fixed;
}
HTML(用于 div):
<div id='top'>Kitchen List</div>