【发布时间】:2020-08-05 07:50:01
【问题描述】:
目前我有这样的设置 在 html 中一个简单的父容器,其中 A、B、C 子元素重复。
A | B
_____
C
A | B
_____
C
A | B
_____
C
a) 通过只更改 css(而不是 html),我想将顺序更改为这样
B | A
_____
C
B | A
_____
C
B | A
_____
C
b) 还有这样的变种
A | B
_____
C
B | A
_____
C
A | B
_____
C
这样的模式应该永远重复
我的代码:
.grid{
display:inline-grid;
grid-template-columns: repeat(2, 1fr);
grid-auto-rows:0 50px;
grid-column-gap: 0px;
grid-row-gap: 0px;
// A
& :nth-child(3n+1) {
vertical-align: bottom;
position:relative;
bottom:-22px;
right:15px;
}
// B
& :nth-child(3n+2) {
position:relative;
left:-3px;
}
// C
& :nth-child(3n+3) {
grid-column: span 2;
justify-self: center;
}
}
【问题讨论】: