Если у меня есть следующая структура HTML:
<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>
Следующий 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>
Я хочу, чтобы слоты в форме пирамиды выглядели так. Как это сделать, сохраняя тот же 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)
@TemaniAfif Можем ли мы сделать это с помощью сетки CSS?
пирамида это не сетка
@TemaniAfif Я пробую ваш css и редактирую свой css, но он совсем не похож на пирамиду, я редактирую свой вопрос, публикуя весь свой css
@ TemaniAfif Я не знаю, как контролировать ширину и высоту слота, я хочу, чтобы карты были достаточно большими, чтобы можно было перетаскивать карты, они настолько малы для этой функции.






вы начали использовать сетку, почему бы не использовать позиционирование каждого элемента
.slots-container {
display: grid;
grid-template-columns: repeat(12, 1fr);
grid-template-rows: repeat(3, 1fr);
grid-gap: 5px;
width: 100vw;
height: 100vh;
}
.slot {
display: flex;
align-items: center;
justify-content: center;
}
.slot:nth-child(1) {
grid-area: 2 / 3 / 3 / 7;
background-color: rgba(163, 34, 173, 0.5);
}
.slot:nth-child(2) {
grid-area: 2 / 7 / 3 / 11;
background-color: rgba(30, 203, 81, 0.5);
}
.slot:nth-child(3) {
grid-area: 1 / 5 / 2 / 9;
background-color: rgba(58, 215, 181, 0.5);
}
.slot:nth-child(4) {
grid-area: 3 / 1 / 4 / 5;
background-color: rgba(178, 166, 72, 0.5);
}
.slot:nth-child(5) {
grid-area: 3 / 5 / 4 / 9;
background-color: rgba(103, 177, 182, 0.5);
}
.slot:nth-child(6) {
grid-area: 3 / 9 / 4 / 13;
background-color: rgba(122, 201, 176, 0.5);
}<div class = "slots-container">
<div class = "slot">1</div>
<div class = "slot">2</div>
<div class = "slot">3</div>
<div class = "slot">4</div>
<div class = "slot">5</div>
<div class = "slot">6</div>
</div>Вы можете определить треугольный grid-template-areas в своем slots-container и назначить соответствующий grid-area конкретному .slot:
.slots-container {
display: grid;
gap: 0.3125rem;
grid-template-areas: ". . a a . ."
". b b c c ."
"d d e e f f";
}
.slot:nth-child(1) { grid-area: b }
.slot:nth-child(2) { grid-area: c }
.slot:nth-child(3) { grid-area: a }
.slot:nth-child(4) { grid-area: d }
.slot:nth-child(5) { grid-area: e }
.slot:nth-child(6) { grid-area: f }
/* eye-candy only */
.slot {
min-height: 18rem;
border: 2px solid black;
background-color: Silver;
display: grid; place-items: center;
font-size: 3vw;
}<div class = "slots-container">
<div class = "slot">1</div>
<div class = "slot">2</div>
<div class = "slot">3</div>
<div class = "slot">4</div>
<div class = "slot">5</div>
<div class = "slot">6</div>
</div>Большое спасибо