如果我有以下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>
根据@Rene的回答:
<style>
.slots-container {
display: grid;
gap: 0.3125rem;
grid-template-areas: ". . a a . ."
". b b c c ."
"d d e e f f";
margin: 1px;
overflow-x: hidden;
}
.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: 15.2rem;
background-color: Silver;
display: grid;
place-items: center;
font-size: 3vw;
padding: 5px 1px 5px 1px;
position: relative;
cursor: pointer;
transition: background-color 0.3s ease;
align-items: center;
justify-content: center;
width: 370px;//The problem
border-radius: 20px;
height: 15.2rem;
}
.slot:nth-child(3) {
background: linear-gradient(135deg, #b6d7a8, #ffd3b6);
}
.slot:nth-child(2),
.slot:nth-child(1) {
background: linear-gradient(135deg, #c7b8e1, #ffe0e0);
}
.slot:nth-child(4),
.slot:nth-child(5),
.slot:nth-child(6) {
background: linear-gradient(135deg, #a8cbd4, #ffe6b6);
}
</style>
我想要像apyramid这样的插槽形状,如何做到保持相同的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)