有没有办法在网格间隙上伸展网格项目?
我有一个容器和一个孩子
.container {
display: grid;
grid-template-columns: repeat(21, 1fr);
gap: 20px;
width: 100%;
}
.container .child {
grid-column: 1/ 4;
}
是否有一种方法可以将.Child
在第5列旁边带上)
I have a container and a child
.container {
display: grid;
grid-template-columns: repeat(21, 1fr);
gap: 20px;
width: 100%;
}
.container .child {
grid-column: 1/ 4;
}
Is there a way to bring the .child
next to column 5 (so to column 4 plus the 20px
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 mdn docs :
因此,您必须将内容与
rain -right:-20px
重叠您的内容。According to the MDN docs :
Therefore you have to overlap your content above that gap with
margin-right: -20px
如果您想要
.Child
列5
ie第4列
加上20px
,如您所述。解决的简单方法是将
保证金:-20px
添加到child
希望它能有所帮助!
If you want
.child
next to thecolumn 5
i.ecolumn 4
plus the20px
as you mentioned.The easy way around is to add
margin-right: -20px
to thechild
Hope it helps!