这个问题我已经看过几次了,但我还没有能够重新利用所发布的代码。
我正在尝试更改Squarespace中照片网格的顺序,以便它在桌面上显示一种方式,但在移动设备上重新排序。
我有索引画廊页面,用于替换图像布局(对于全出血,我有两个并排的图像,其中一个上有文本)。我已经改变了桌面上的顺序,所以section1 =图片在左边,图片在右边,section2 =图片在左边,图片在右边(总共有4个部分)。
在移动视图上,流程是将图像堆叠在一起,因此我得到了image/image with text/image with text/image/image。
我可以改变每个部分中的视图顺序吗?
发布于 2020-05-14 05:05:45
通过CSS Editor添加的以下CSS将执行您所需的操作。
@media screen and (max-width: 640px) {
#new-gallery-1 .Index-gallery-inner {
display: flex;
flex-direction: column;
}
#new-gallery-1 .Index-gallery-item:nth-child(2) {
order: -1;
}
#new-gallery-2 .Index-gallery-inner {
display: flex;
flex-direction: column;
}
#new-gallery-2 .Index-gallery-item:nth-child(2) {
order: -1;
}
}或者,如果您喜欢较少的CSS,前缀版本:
@media screen and (max-width: 640px) {
#new-gallery-1, #new-gallery-2 {
.Index-gallery-inner {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
}
.Index-gallery-item:nth-child(2) {
-webkit-box-ordinal-group: 0;
-ms-flex-order: -1;
order: -1;
}
}
}仅使用上述代码片段中的一个。它们所做的是使用flexbox来调整宽度小于640px的元素的显示顺序。
请注意,这是通过id将部分作为目标来实现的,这些部分是使用索引页的URL设置的。因此,如果您在Squarespace的后端更改了索引页面的URL (更改为除new-gallery-1和new-gallery-2之外的其他内容),则必须更新CSS。类似地,如果您添加更多的节,您可能希望将它们添加到CSS。
https://stackoverflow.com/questions/61779982
复制相似问题