gpt4 book ai didi

javascript - css 破烂的底部,是什么意思?

转载 作者:行者123 更新时间:2023-12-02 21:52:08 25 4
gpt4 key购买 nike

查看不同的 masonry 方法,特别是查看此处的摘要

https://css-tricks.com/piecing-together-approaches-for-a-css-masonry-layout/

有人说:“竖排底参差不齐可以吗?”

用一支编码笔理论上可以显示这个破烂的底部,在这里 https://codepen.io/chriscoyier/pen/NeRNBO或这里https://codepen.io/chriscoyier/pen/XojXxy

但我看不到破烂的底部在哪里

要么我需要一些线索,要么这是浏览器已经解决的问题?

(codepen中的方法,纯css)

.masonry-with-columns {
columns: 6 200px;
column-gap: 1rem;
div {
width: 150px;
background: #EC985A;
color: white;
margin: 0 1rem 1rem 0;
display: inline-block;
width: 100%;
text-align: center;
font-family: system-ui;
font-weight: 900;
font-size: 2rem;
}
@for $i from 1 through 36 {
div:nth-child(#{$i}) {
$h: (random(400) + 100) + px;
height: $h;
line-height: $h;
}
}
}

(或者基于 Flex 的)

.masonry-with-flex {
display: flex;
flex-direction: column;
flex-wrap: wrap;
max-height: 1000px;
div {
width: 150px;
background: #EC985A;
color: white;
margin: 0 1rem 1rem 0;
text-align: center;
font-family: system-ui;
font-weight: 900;
font-size: 2rem;
}
@for $i from 1 through 36 {
div:nth-child(#{$i}) {
$h: (random(400) + 100) + px;
height: $h;
line-height: $h;
}
}
}

codepen1

最佳答案

您问题中的屏幕截图所展示的是底部破烂的完美示例。事实上,链接的文章指出您需要接受“垂直排序和锯齿状底部”。

目前仅使用 CSS 无法实现齐平 masonry 。一个subsequent section标题为您需要干净的底部边缘吗? Flexbox/JavaScript 组合可以提供帮助。 演示了一种有效的混合方法。

关于javascript - css 破烂的底部,是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60107581/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com