我正在尝试使用CSS创建一个非常简单的模态框,并希望为“vignette”和主要内容使用单个DOM元素。到目前为止,我已经完成了以下步骤:
<div class="modal"></div>
.modal {
position: fixed;
top: 20%;
left: 50%;
right: 50%;
width: 620px;
margin: 0 -320px;
height: 540px;
background: $white;
z-index: 4000;
}
/* Vignette */
.modal:before {
content: "";
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: $black;
z-index: 2000
}
很遗憾,这会导致小插图显示在模态框的上方(而不是如期望的那样在其后面)。如何强制将其置于下方,而无需为其创建新的 div?
background: $white;
是什么意思? - Mike Samuel