简体   繁体   English

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

[英]fixed div, content fixed but background-image not

I'm having trouble creating a fixed div on top of my webpage. 我在网页顶部创建固定div时遇到问题。 This is what I have : 这就是我所拥有的:

<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: 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.. 更新:当我向下滚动时,标题应始终固定在屏幕顶部。

try with adding position:fixed; 尝试添加position:fixed; to your #headcont 到你的#headcont

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM