html - 将菜单栏的阴影带到背景图像的前面

标签 html css xhtml

如何使菜单阴影出现在 div 背景图像前面?

这是我的 CSS

nav {
    width:900px;
    margin: 4px auto 0px 8%;
    font-size: 16pt;
    padding-bottom: 0px;

  -moz-box-shadow:    7px 8px 3px 1px black;
  -webkit-box-shadow: 7px 8px 3px 1px black;
  box-shadow:         7px 8px 3px 1px black;
}

.mainContent {
    margin: 0px auto;
    width: 1200px;
    height:100%;
    padding-top:0px;   

    background-color: #0e23a4;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#0e23a4), to(#999999));
    background-image: -webkit-linear-gradient(top, #0e23a4, #999999);
    background-image: -moz-linear-gradient(top, #0e23a4, #999999);
    background-image: -o-linear-gradient(top, #0e23a4, #999999);
    background-image: linear-gradient(to bottom, #0e23a4, #999999);   

  -webkit-box-shadow: 0px 15px 9px 8px black;
  box-shadow: 0px 15px 9px 8px black;

}

.bodyMain {
    width: 100%;
    height:100%;

    border:1px solid white;
    background-image:url("/Content/images/phoenix.jpg");
}

HTML

    <nav>
        <ul id="menu1">
            ...
        </ul>
    </nav>
    <div class="bodyMain">
        <div class="mainContent">
            ...
        </div>
    </div>

最佳答案

尝试将 z-index:9; 添加到您的导航部分。

这会将 nav 部分带到顶层。

关于html - 将菜单栏的阴影带到背景图像的前面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12906453/

相关文章:

html - 如何检测我的浏览器是否为 Firefox?

css - 如何在 SASS 中迭代列表时使用 map 函数?

css - nth-child 转换为 IE 支持

javascript - Bootstrap,内联输入在动态添加时具有更小的间隙

html - 这个标记有什么 "wrong"吗?

html - 如何使用 col-md 水平居中对齐内容

javascript - 为什么 .setAttribute() 和 .removeAttribute 方法在我的 javascript 代码中不起作用?

html - 修复页眉/页 footer 分在 css 中的文本对齐

html - XHTML 标签在 HTML 中有效吗?

css - 为 div 扩展全高