[英]Keep both background and menu bar fixed in position
我试图同时修复菜单栏和背景位置。
因此,我将此代码添加到正文中以固定背景的位置:
<body style ="width: 100%; background-image: url(images/bkgd3_1260_black.jpg); background-attachment:fixed; background-size: cover; background-position:center;>
<div id="menu-bar"> xxxxx
</div>
<---other content--->
</body>
我在head标签下放置了一个代码,用于固定菜单栏的位置,即:
<head>
<style type="text/css">
#menu-bar {
position: fixed;
left: 0px;
top: 0px;
width: 1000px;
height: 25px;
z-index: 100;
background-color: #040404;
font-family: Calibri;
font-size: 16px;
font-style: normal;
text-transform: none;
text-decoration:none;
color: rgb(231,231,231);
line-height: normal;
letter-spacing: normal;
text-align: left;
word-spacing: normal;
display: table-row;
background-repeat: no-repeat;
border-bottom-width: thin;
border-bottom-style: solid;
border-left-style: none;
border-right-style: none;
border-top-style: none;
border-bottom-color: rgb(204,255,38);
}
</style>
<head>
但是,结果是:背景是固定的,但菜单栏不是固定的。 当我向下滚动时,菜单栏就消失了。 我实际上希望它保持在最高位置。
有什么建议么?
您在体式声明中缺少结尾处的“。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.