<section>
<div class="grid__container">
<div class="grid__item" item-name="tom">
<span>Tom</span>
</div>
<div class="grid__item" item-name="jack">
<span>Jack</span>
</div>
<div class="grid__item" item-name="lucy">
<span>Lucy</span>
</div>
<div class="grid__item" item-name="nick">
<span>Nick</span>
</div>
</section>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
min-height: 100vh;
display: flex;
justify-content: center;
flex-direction: column;
gap: 20px;
font-family: "Exo", Arial, sans-serif;
background-color: #f7f7f7;
padding: 20px;
}
section {
width: 100%;
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
}
.grid__container {
border: 1px dashed #f36;
box-shadow: 0 0 0 6px rgb(0 0 0 / 13%);
border-radius: 1px;
position: relative;
}
.grid__item {
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
background-color: #f7f7f7;
font-size: 2rem;
color: #fff;
text-shadow: 1px 1px 0 rgb(0 0 0 / 0.5), -1px -1px 0 rgb(0 0 0 / 0.05);
font-weight: 500;
}
.grid__item:nth-child(1) {
background-color: #f1c2c6;
}
.grid__item:nth-child(2) {
background-color: #dac2f1;
}
.grid__item:nth-child(3) {
background-color: #ccf1c2;
}
.grid__item:nth-child(4) {
background-color: #c2e9f1;
}
.grid__container {
width: 802px;
display: grid;
grid-template-columns: 2fr 1fr 1fr 1fr;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.