Anton2
1
.palette-box:nth-child(1) .palette-small {
display: flex;
flex-direction: column;
justify-content: center;
}
.palette-box:nth-child(1) .palette-small .color-3 {
order: -1;
align-self: center;
}
.palette-box:nth-child(1) .palette-small .color-2 {
order: 1;
}
.palette-box:nth-child(1) .palette-small .color-4 {
order: 2;
align-self: center;
}
.palette-box:nth-child(2) .palette-small {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.palette-box:nth-child(2) .palette-small .color-1 {
order: -2;
align-self: flex-start;
}
.palette-box:nth-child(2) .palette-small .color-4 {
order: -1;
align-self: flex-start;
}
.palette-box:nth-child(2) .palette-small .color-6 {
order: 1;
align-self: flex-end;
}
.palette-box:nth-child(2) .palette-small .color-2 {
order: 2;
align-self: flex-end;
}
.palette-box:nth-child(3) .palette-small {
display: flex;
justify-content: space-between;
}
.palette-box:nth-child(3) .palette-small .part:first-child {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.palette-box:nth-child(3) .palette-small .part:last-child {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.palette-box:nth-child(4) .palette-small {
display: flex;
justify-content: space-between;
}
.palette-box:nth-child(4) .palette-small .part:first-child {
display: flex;
}
.palette-box:nth-child(4) .palette-small .part:last-child {
display: flex;
flex-direction: column-reverse;
justify-content: space-between;
}
Можно значительно сократить…
Например, свойство display: flex; вместо восьми раз можно записать в одном месте…
Или эти два правила:
.palette-box:nth-child(3) .palette-small .part:first-child {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.palette-box:nth-child(3) .palette-small .part:last-child {
display: flex;
flex-direction: column;
justify-content: space-between;
}
как минимум можно было записать:
.palette-box:nth-child(3) .palette-small .part:first-child,
.palette-box:nth-child(3) .palette-small .part:last-child {
display: flex;
flex-direction: column;
justify-content: space-between;
}
Однако – смотрим в HTML, смотрим где и сколько элементов с классом .part.
Всего по два в каждом родителе во всём коде.
Сокращаем запись:
.palette-box:nth-child(3) .part {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.palette-small,
.part {
display: flex;
align-content: space-between;
}
/*первый квадрат*/
.palette-box:nth-child(1) .palette-small {
flex-direction: column-reverse;
justify-content: center;
}
.palette-box:nth-child(1) .color-4 {
order: -1;
align-self: center;
}
.palette-box:nth-child(1) .color-3 {
order: 1;
align-self: center;
}
/*второй квадрат*/
.palette-box:nth-child(2) .palette-small {
flex-direction: column-reverse;
justify-content: space-between;
align-items: flex-start;
}
.palette-box:nth-child(2) .color-2,
.palette-box:nth-child(2) .color-6 {
align-self: flex-end;
}
.palette-box:nth-child(3) .palette-small,
.palette-box:nth-child(4) .palette-small {
justify-content: space-between;
}
/*третий квадрат*/
.palette-box:nth-child(3) .part{
flex-direction: column;
justify-content: space-between;
}
/*четвёртый квадрат*/
.palette-box:nth-child(4) .part:last-child {
flex-direction: column-reverse;
justify-content: space-between;
}
Anton2
3
Хорошо, спасибо за ответ!