html - CSS z 索引 : "position: relative;" element on top of "position: fixed;" element - It will not work

标签 html css position z-index

我在 af 固定定位标题中有一个下拉菜单,我希望下拉框出现在另一个固定定位元素的前面。 我已经尝试在两个元素上使用 z-index,并且我已经检查过,两个元素都有一个位置。

参见 fiddle :http://jsfiddle.net/ng8u8zjx/1/

下拉框显示在包含“+”的元素后面。我想要它在前面。

    .dashboard-header {
        width: 100%;
        height: 50px;
        position: fixed;
        top: 0;
        background-color: #FF555F;
    }
...
    .dashboard-header .user-menu ul ul {
        display: none;
        background-color: #FF555F;
        height: auto;
        text-align: center;
        z-index: 10;
        position: relative;
    }
...
    /* ADD NEW START */
    article.content header a.add-new {
        color: #FFF;
        line-height: 32px;
        text-align: center;
        background-color: #FF555F;
        border-radius: 5px;
        width: 30px;
        height: 30px;
        display: block;
        position: fixed;
        right: 10px;
        top: 60px;
        font-size: 22px;
        text-decoration: none;
        z-index: 1;
    }

最佳答案

您必须将 z-index 设置为容器 .dashboard-header

.dashboard-header {
    z-index: 2;
}

fiddle :http://jsfiddle.net/ng8u8zjx/2/

关于html - CSS z 索引 : "position: relative;" element on top of "position: fixed;" element - It will not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27082217/

相关文章:

html - 生成缩短类名

javascript - 使用 JS 或 JQUERY 选择页面加载时的第一个 html 表行

php - 我使用的 jQuery 未检测到 CSS 正文 :after

html - 延迟 :hover using CSS?

video - 随机位置的FFmpeg文本

相对于列宽或屏幕尺寸的 CSS 图像位置

html - 'glyphicon glyphicon-plus' 不显示

HTML:使用 rowspan 控制表格中的单个行高

html - 如何使 <textarea> 使用剩余的可用高度

html - 左侧导航的 CSS 定位