html - 内容在横幅上和标题下滚动时出现问题

标签 html css

所以我有一个固定的 header ,它有 z-index:10,在它下面是一个固定的横幅,然后在它下面是一个相关的内容容器。我想要的是内容在横幅上滚动但在标题下方。但是,当我尝试滚动时它不起作用。对我来说奇怪的是,每当我将 box-shadow: 0px 0px 2px rgb(100,100,125); 添加到内容容器时,它都会执行我想要的操作。我正在使用以下代码:

* {
    padding: 0;
    margin: 0 auto;
}

body {
    background: rgb(223,227,238);
    text-align: center;
}

#body_container {
    padding-top: 80px;
}

#banner_container {
    position: fixed;
    left: 0;
    right: 0;
}

#banner {
    width: 1024px;
    height: 300px;
}

#content_container {
    background: rgb(243,247,248);
    max-width: 1024px;
    height: 100%;
    position: relative;
    top: 300px;
    box-shadow: 0px 0px 2px rgb(100,100,125);
}

header {
    min-width: 100%;
    background: rgb(50,50,50);
    height: 80px;
    position: fixed;
    z-index: 10;
}

/* Header styling, not relevant */
#header_container {
    max-width: 1024px;
    height: 100%;
}

#header_container div {
    float: left;
    display: inline-block;
    width: 25%;
}

#logo {
    width: 50%;
    height: auto;
}

.menuItem {
    padding-top: 29px;
    height: calc(100% - 29px);
    border: 0;
    text-align: center;
    font-family: Signika;
    font-size: 25px;
    color: rgb(203,207,218);
}

.menuItem:hover {
    border-bottom: 4px solid rgb(59,89,202);
    height: calc(100% - 33px);
    color: rgb(160,170,218);
}

.menuLogo {
    padding-top: 14.5px;
    height: calc(100% - 14.5px);
    border: 0;
    text-align: center;
}

#mobile_menu_button {
    display: none;
}
<header>
    <div id="header_container">
        <div class="menuLogo">
            <img id="logo" src="img/desygn%20logo%20website.png">
        </div>
        <div class="menuItem">Home</div>
        <div class="menuItem">Over</div>
        <div class="menuItem">Contact</div>
                
        <div id="mobile_menu_button">
                    
        </div>
    </div>
</header>
        
<div id="body_container">
    <div id="banner_container">
        <img id="banner" src="img/banner_website.png">
    </div>
            
    <div id="content_container">
    </div>
</div>

最佳答案

在您的代码中,您没有在 content_container 下添加任何内容。我没有看到您的代码有任何问题。它工作正常。检查here有内容

关于html - 内容在横幅上和标题下滚动时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29721458/

相关文章:

html - CSS 不适用于 XHTML

asp.net-mvc - 为什么 <form> 被赋予 NoValidate 属性?

html - 旋转 block 元素

相对于父元素的边框调整子元素的大小

javascript - 如何优化以下设置元素 CSS 属性的 JavaScript

html - 如何正确使用媒体查询根据显示宽度更改样式?

html - Bootstrap div作为表td,中间文本

html - 是否可以添加仅针对特定浏览器显示的 css 样式

html - Mojolicious 响应的基本 URL

html - 如何在网站上的多个登录字段上使用自动填充