<div class="modal z-10">
<div class="modal__body">
<h2 class="modal__title">Modal Title</h2>
<button class="modal__close-button">x</button>
</div>
</div>
<header>
<h1 class="header__title">Labzindex</h1>
<button class="header__call-to-action z-0">call us</button>
</header>
<div class="posts-wraper z-0">
<div class="posts">
<article class="posts__item">Post 1</article>
<article class="posts__item">Post 2</article>
<article class="posts__item">Post 3</article>
<article class="posts__item">Post 4</article>
</div>
</div>
html {
--red: #bc442f;
--green: #007b7d;
--green: #007b7d;
--yellow: #ffc978;
}
body {
background: var(--yellow);
}
h1 {
margin: 0;
color: var(--yellow);
}
body,
html {
padding: 0;
margin: 0;
}
header {
background: var(--red);
padding: 16px;
text-align: center;
display: flex;
align-items: center;
justify-content: space-around;
h1 {
color: var(--yellow);
}
}
.header__call-to-action {
z-index: 2;
border: none;
text-transform: uppercase;
padding: 12px;
border-radius: 4px;
color: #f2f2f6;
font-weight: bold;
background: var(--green);
}
.modal {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
background: hsla(0, 0%, 0%, 0.42);
}
.modal__body {
position: relative;
color: var(--yellow);
background: var(--green);
height: 90%;
max-width: 500px;
flex: 1;
margin: 0 auto;
padding: 16px;
box-sizing: border-box;
}
.modal__close-button {
position: absolute;
top: -20px;
right: -20px;
width: 50px;
border: none;
height: 50px;
font-size: 24px;
border-radius: 100%;
}
.modal__title {
font-size: calc(36 / 16 * 1rem);
margin: 0;
top: 0;
left: 16px;
}
.posts {
display: grid;
max-width: 600px;
grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
gap: 20px;
margin: 30px auto;
position: relative;
z-index: 1;
&__item {
background: white;
font-size: calc(24 / 16 * 1rem);
height: 150px;
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
}
}
$zIndex: (
"0": 0,
"10": 10,
"20": 20,
"30": 30,
"40": 40,
"50": 50,
"60": 60,
"70": 70,
"80": 80,
"90": 90,
"100": 100,
"auto": "auto",
);
@each $index, $level in $zIndex {
.z-#{$index} {
z-index: $level;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.