固定div,内容固定但背景图像不固定

时间:2022-12-29 21:26:03

I'm having trouble creating a fixed div on top of my webpage. This is what I have :

我在网页上创建固定div时遇到问题。这就是我所拥有的:

<header id="headerCntr">
    <div id="headcont">
        <!--  / language box \ -->
        <article class="languageBox">
            <ul>
                <li class="selected"><a href="/nl">NL</a></li>
                <li><a href="/en">EN</a></li>
            </ul>

        </article>

        <div class="clear"></div>

        <a href="/nl/" class="logo">front.text.seotitlemuseeuwbikes</a>

        <article class="searchBox">

            <form>
                <dl class="zend_form">

                    <dd>
                        <input>
                    </dd>

                    <dd>

                        <input id="element1" class="button" type="button" value="submit">

                    </dd>
                </dl>
            </form>

        </article>

        <nav class="menuBox">
            <ul class="menu">
                <li>
                    <a href="/nl/fietsen">Fietsen</a>
                </li>
                <li>
                    <a href="/nl/technologie">technologie</a>
                </li>
                <li>
                    <a href="/nl/over-museeuwbikes">Over ons</a>
                </li>
                <li>
                    <a href="/nl/service">service</a>
                </li>
                <li>
                    <a href="/nl/planet-museeuw">Planet museeuw</a>
                </li>
                <li>
                    <a href="/nl/nieuws">nieuws</a>
                </li>
                <li>
                    <a href="/nl/partners">partners</a>
                </li>
            </ul>
        </nav>
    </div>
</header>

CSS:

#headerCntr {
    position:fixed; 
    width:100%; 
    top:0; 
    background: 
    url('../images/header-960.png') top left repeat-y; 
    height:150px;
}
#headcont{
    margin:0 auto;
    width:1200px;
}

My content is always on top, but the background-image not .. How can I fix this?

我的内容总是在顶部,但背景图像不是..我该如何解决这个问题?

UPDATE: When I scroll down the header should always be fixed on my top of screen..

更新:当我向下滚动时,标题应始终固定在我的屏幕顶部..

1 个解决方案

#1


1  

try with adding position:fixed; to your #headcont

尝试添加位置:固定;到你的#headcont

#1


1  

try with adding position:fixed; to your #headcont

尝试添加位置:固定;到你的#headcont