gpt4 book ai didi

javascript - 如何水平渲染元素(Masonry Layout)?

转载 作者:行者123 更新时间:2023-12-05 04:30:21 25 4
gpt4 key购买 nike

我想在页面加载时水平呈现元素,请引用下图

<section
tabindex="-1"
class="relative mx-8 mt-10 mb-20 max-w-7xl focus:outline-none sm:mx-16 md:mx-20 lg:mx-24 xl:mx-auto"
>
<ul
class="h-full w-full list-none columns-1 gap-4 space-y-12 overflow-hidden pb-32 md:columns-2 lg:columns-3 lg:gap-8 xl:columns-4"
>
<ExploreCard
v-for="(post, index) in posts.data"
:key="index"
:post="post"
:canLike="this.canLike"
/>
</ul>
</section>

当前

enter image description here

预期

enter image description here

像这样,
https://reactjsexample.com/rendering-columns-from-a-list-of-children-with-horizontal-ordering/

I am looking for a Js, Vue, or CSS solution.

最佳答案

我最终得到了一个包解决方案,它工作得很好!

DaPotatoMan/vue-next-masonry

这是它的样子

<masonry
:cols="{ default: 4, 1024: 3, 768: 2, 640: 1 }"
:gutter="{ default: 40, 1024: 30, 768: 20 }"
>
<div v-for="(post, index) in posts.data" :key="index" class="mb-10">
<ExploreCard
v-for="(post, index) in posts.data"
:key="index"
:post="post"
:canLike="this.canLike"
/>
</div>
</masonry>

这样一来,所有的帖子都是按水平顺序呈现的!

关于javascript - 如何水平渲染元素(Masonry Layout)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72085236/

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