gpt4 book ai didi

css - 使用 Masonry 将一组图像居中

转载 作者:技术小花猫 更新时间:2023-10-29 11:46:56 24 4
gpt4 key购买 nike

我在一组图像上使用 Masonry.js 并试图将整个组居中。当我指定容器网格的宽度并设置 margin:0 auto 时,我已经让组居中,但我希望使用更流畅的网格或百分比将其居中。 (我意识到我可以使用媒体查询来更改固定宽度,但正在寻找更无缝的选项。)

Here is an example固定宽度的代码居中就好了。

here is an example我试图居中但 margin:0 auto 不工作的更流畅的例子。

最佳答案

您可以使用 isFitWidth 参数使砌体布局居中:http://masonry.desandro.com/demos/centered.html

$('.container').masonry({ isFitWidth: true });

此参数将设置容器的 width 值,这将允许您使用 CSS 将容器居中:

.container {
margin: 0 auto;
}

关于css - 使用 Masonry 将一组图像居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13907080/

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