gpt4 book ai didi

javascript - 来自父级的左右元素

转载 作者:太空宇宙 更新时间:2023-11-04 00:35:51 25 4
gpt4 key购买 nike

当您从父级向左和向右添加元素时,是否有一种方法可以均匀分布元素,父级在中间?

example

最佳答案

这是否解决了您的问题(使用网格)?

#container{
display:grid;
grid-template-columns:repeat(3, auto);

border:solid 1px black;
}
#root{
grid-column:2;
grid-row:1/1000; /* If you know the number of element you can replace 1000 by nbElement/2 */

background-color: red;
}

.element{
background-color:grey;
}
<div id='container'>
<div id='root'>Root</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
<div class='element'>Element</div>
</div>

关于javascript - 来自父级的左右元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59444218/

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