html - box-shadow 不会显示在 div 的底部

标签 html css

我有一个看起来像这样的页面:

box-shadow http://www.morninj.com/images/box-shadow-screenshot.png

中间的 div(以“Quotation.”作为其内容)应用了 box-shadow 属性。出于某种原因,如果存在第三个 div,则阴影不会出现在第二个 div 下面。有人知道为什么吗?

HTML:

<div id="header">
    <h1>Title</h1>
</div><!--/#header-->
<div id="subheader">
    <h2>"Quotation."</h2>
</div><!--/#subheader-->
<div id="blurb">
    <div id="blurb-container">
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div><!--/#blurb-container-->
</div><!--/#blurb-->

CSS:

div#header {
    background-color: #444;
    padding: 20px 0;
}

    div#header h1 {
        color: #fff;
        font-family: 'Arvo', sans-serif;
        font-size: 50px;
        font-weight: bold;
        text-align: center;
        text-shadow: 1px 1px 1px #000;
    }

div#subheader {
    background-color: #777;
    box-shadow: 0 0 3px 2px #333;
    padding: 10px;
}

    div#subheader h2 {
        color: #efefef;
        font-family: 'Merriweather', serif;
        font-size: 14px;
        font-style: italic;
        line-height: 24px;
        text-align: center;
    }

div#blurb {
    background-color: #efefef;
    padding: 20px;
}

    div#blurb div#blurb-container {
        margin: 0 auto;
        width: 800px;
    }

最佳答案

你的“宣传”掩盖了它。将 div#blurb css 规则编辑为以下内容,将其移到阴影 div 后面:

div#blurb {
    background-color: #efefef;
    padding: 20px;
    position:relative;
    z-index:-1;
}

关于html - box-shadow 不会显示在 div 的底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5566291/

相关文章:

javascript - 通过JSON技术扫描

java - 在我的应用程序中将外部网页显示到网页中

CSS - em 应该用于边距和填充

javascript - 在 JS 中进行全尺寸跳跃之前,角色会先做一个小跳跃

jquery - 溢出滚动不适用于 Android 触摸屏

javascript - 如何使用图像或文本更改单选按钮以及如何使用 onclick

javascript - 本地存储和本地文件

html - Facebook Like 按钮与其他社交按钮不一致。使用 CSS 来解决这个问题,但在其他浏览器中会中断

javascript - 如何动态调整 Spotfire 文本区域的大小

html - 如何使用 CSS 将导航栏更改为选项卡?