保持背景和菜单栏固定到位



我试图修复菜单栏和背景的位置。

所以我将这段代码添加到正文中以修复背景的位置:

<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>

但是,结果是:背景是固定的,但菜单栏不是。 当我向下滚动时,菜单栏只是消失了。我实际上希望它保持在最顶端。

有什么建议吗?

您的体型声明中缺少结束语。

最新更新