If I have the following HTML structure:
<div class="slots-container">
<div class="slot"></div>
<div class="slot"></div>
<div class="slot"></div>
<div class="slot"></div>
<div class="slot"></div>
<div class="slot"></div>
</div>
The following CSS:
<style>
.slots-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 5px;
}
.slot {
border: 2px dashed #ccc;
padding: 5px;
min-height: 300px;
position: relative;
cursor: pointer;
transition: background-color 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
}
.slot:nth-child(3) {
background: linear-gradient(to bottom right, #e66465, #9198e5);
}
.slot:nth-child(2),
.slot:nth-child(1) {
background: linear-gradient(to top left, #EAEAEA, #C4C4C4);
}
.slot:nth-child(4),
.slot:nth-child(5),
.slot:nth-child(6) {
background: linear-gradient(to top left, #D9D9D9, #ADADAD);
}
.slot:hover {
background-color: #f0f0f0;
}
.slot::before {
content: "Drop Expert Card Here";
position: absolute;
top: 1px;
left: 1px;
width: 100%;
height: 40px;
background-color: #ffd700;
color: #fff;
font-size: 14px;
font-weight: bold;
display: flex;
align-items: center;
justify-content: center;
font-family: inherit;
color: black;
border-bottom: 1px;
border-color: dimgrey;
margin-bottom: 5px;
}
.slot:nth-child(3)::before {
content: "خبير صناعة فئة-أ";
background-color: #ffd700;
text-align: center;
}
.slot:nth-child(2)::before,
.slot:nth-child(1)::before {
content: "خبير صناعة فئة-ب";
background-color: #c0c0c0;
text-align: center;
}
.slot:nth-child(4)::before,
.slot:nth-child(5)::before,
.slot:nth-child(6)::before {
content: "خبير صناعة فئة-ج";
background-color: #cd7f32;
text-align: center;
}
#temp_emp {
display: flex;
align-items: center;
justify-content: center;
min-height: 280px;
background-color: #f9f9f9;
border: 2px dashed #ccc;
}
.placeholder1 {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 5px;
text-align: center;
border: 2px dashed #999;
background-color: #f9f9f9;
}
.placeholder-text {
color: #999;
font-weight: bold;
font-size: 14px;
margin-bottom: 10px;
}
.arrow-icon {
width: 20px;
height: 20px;
background-color: #999;
border-radius: 50%;
margin-bottom: 10px;
}
.placeholder1:hover {
background-color: #f0f0f0;
}
.placeholder1:before {
font-size: 1.2rem;
color: #888;
opacity: 0.6;
}
.temp-emp-card {
width: 250px;
height: 250px;
border: 2px solid #999;
margin: 5px;
background-color: #fff;
}
.card {
background-color: #f8f8f8;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 1px;
text-align: center;
transition: background-color 0.3s ease;
}
.card:hover {
background-color: #f0f0f0;
}
.emp-photo {
margin-bottom: 15px;
}
.emp-photo img {
width: 130px;
height: 130px;
border-radius: 50%;
object-fit: cover;
border: 4px solid #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.card-title {
font-size: 15px;
font-weight: bold;
margin-bottom: 5px;
margin-top: 5px;
padding: 8px 16px;
background-color: #e2e2e2;
color: #333;
border-radius: 20px;
display: inline-block;
}
.card-text {
font-size: 14px;
color: #888;
}
.delete-button {
position: absolute;
top: 5px;
right: 5px;
font-size: 1.5rem;
color: #dc3545;
cursor: pointer;
}
.details-button {
position: absolute;
top: 5px;
left: 5px;
font-size: 1.5rem;
color: #dc3545;
cursor: pointer;
}
.card-body {
padding: 1px;
}
</style>
I want the slots like apyramid shape like this, How to do that maintaining the same HTML:
slot:nth-child(3)
slot:nth-child(1) slot:nth-child(2)
slot:nth-child(4) slot:nth-child(5) slot:nth-child(6)
2
Answers
you began to use grid, why not using positioning of each element
You can define a triangular
grid-template-areas
in yourslots-container
and assign the relevantgrid-area
to a specific.slot
: