这是小提琴。我正在制作杂货清单Web应用程序,并且正在将顶部div固定位置。当我这样做时,div似乎与页面的其余部分重叠。我尝试在css(position: relative; position: fixed
)中使用两个位置,但这不能使div保持固定。
CSS(用于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>
将您的内容包裹起来,div
并赋予其与margin-top
固定内容相同的高度。
的HTML
<div id='top'>Kitchen List</div>
<br />
<div class="container">
<input type='text' id='input'>
<button id='click'>Add</button>
<ol></ol>
<div id='error'>Please enter a grocery item
<br />
<button id='eb'>Close</button>
</div>
</div>
的CSS
.container {
margin-top: 50px;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句