【发布时间】:2021-08-10 15:30:00
【问题描述】:
我正在使用 npm react-masonry-component 为我的页面创建一个类似砖石的网格。我不知道如何让网格在父元素中居中。
我在代码框here上设置了一个演示版
【问题讨论】:
-
是的,没错
我正在使用 npm react-masonry-component 为我的页面创建一个类似砖石的网格。我不知道如何让网格在父元素中居中。
我在代码框here上设置了一个演示版
【问题讨论】:
只需将isFitWidth: true 设置为您传递给砌体组件的选项,如您所见in this forked codepen
const masonryOptions = {
transitionDuration: 0,
fitWidth: true // <-- this option will do the job
};
return (
<section id="artists">
<Masonry
options={masonryOptions}
className={"my-gallery-class masonry"}
elementType={"ul"}
disableImagesLoaded={false}
updateOnEachImageLoad={false}
>
【讨论】: