请教一下CSS布局排列写法?-灵析社区

我爱了你呢

1 2 3 4 不改变HTML下如何使用flex或grid,将其排列成下列效果? 1和4自适应,2与3成上下两行,占剩余空间。 ![image.png](https://wmprod.oss-cn-shanghai.aliyuncs.com/images/20250112/7a0f4d32f11916813e9e0eb318dc74a6.png)

阅读量:360

点赞量:10

问AI
用flex布局: div { display: flex; justify-content: space-between; } em:nth-child(2), em:nth-child(3) { flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; } grid布局: div { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; } em:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; } em:nth-child(2) { grid-column: 2; grid-row: 1; } em:nth-child(3) { grid-column: 2; grid-row: 2; } em:nth-child(4) { grid-column: 3; grid-row: 1 / span 2; }