html - css 布局 z-index 属性中的问题

标签 html css

我希望我的#club-box 位于顶部,然后是::before 框,然后是#club。我已经通过 z-index 属性尝试过这个。我的代码有什么问题。 http://codepen.io/anon/pen/wBzJBW HTML

<div id="club">
    <div class="club-box"> </div>
</div>

CSS

#club {
    z-index: -10000;
    display: block;
    clear: both;
    width: 100%;
    height: 648px;
    background-color: aquamarine;
}

.club-box { 
    z-index: 1000;
    border-radius: 5px;
    display: inline-block;
    margin: 20px;
    width: 300px;
    height: 200px; 
    background: #768;
    position: relative;
}

.club-box::before {
  z-index: 10;
    content: "";
    position: absolute;
    top: 106px;
    left: 17px;
    z-index: 100;
    width: 263px;
    height: 124px;
    background-color: black; 
}

最佳答案

你不能让一个伪元素出现在它的父元素后面。

查看这个相关问题:

Z Index a pseudoelement behind it's parent

关于html - css 布局 z-index 属性中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27638639/

相关文章:

jquery - Bootstrap 水平表格和表格的问题

html - 悬停时隐藏子菜单

jquery - 修改一个简单的 jquery 函数来改变图像的不透明度

css - 使用 main.scss 和子组件 scss 文件嵌套 scss

html - 如何垂直对齐图像和文本

css - 使用 Material-UI 扩展抽屉将页脚保持在底部

javascript - Chart.js 无法创建图表

javascript - 除了输入控件本身之外,如何将文件路径复制到 span 中?

html - 当我将一些内容放在它们旁边时,为什么这些 div 表现得很奇怪?

jquery - 停止 Clippy 显示鼠标悬停文本