这些是被循环出的数据
左边123456 右边789101112
这样排列
我flex布局感觉用的还算熟练,但是这种真的不知道怎么写了 请问有没有人给个思路
可以用 grid
布局实现,具体做法是通过 grid-auto-flow
改变排列流的方向
grid-auto-flow: column;
可以参考张鑫旭的这篇文章 https://www.zhangxinxu.com/wo...
body {
padding: 0;
margin: 0;
}
.container {
width: 100%;
height: 500px;
background-color: antiquewhite;
display: flex;
align-content: stretch;
flex-wrap: wrap;
flex-direction: column;
overflow: scroll;
.child {
width: 200px;
height: 100px;
background-color: aquamarine;
margin: 10px 10px;
}
}
<div class="container">
</div>
let a = 50
function init() {
let $ref = document.getElementsByClassName('container')[0]
console.log($ref)
for (let i = 0; i < a; i++) {
let child = document.createElement('div')
child.setAttribute('class', 'child')
child.innerText = i
$ref.appendChild(child)
}
}
init()
这样就可以
10 回答11.6k 阅读
2 回答3.1k 阅读✓ 已解决
2 回答4.2k 阅读✓ 已解决
5 回答2.2k 阅读
4 回答4.6k 阅读✓ 已解决
3 回答2.7k 阅读✓ 已解决
4 回答2.1k 阅读✓ 已解决
竖向排列,换行就行了。
flex-direction:column;
flex-wrap: wrap;