要在并排放置的DIV之间设置间距,可以使用以下解决方法:
HTML代码示例:
CSS代码示例:
.box {
display: inline-block;
width: 100px;
height: 100px;
margin-right: 10px; /* 设置间距大小 */
}
HTML代码示例:
CSS代码示例:
.container {
display: flex;
justify-content: space-between; /* 设置间距 */
}
.box {
width: 100px;
height: 100px;
}
HTML代码示例:
CSS代码示例:
.container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 10px; /* 设置间距大小 */
}
.box {
width: 100px;
height: 100px;
}
这些是设置并排放置的DIV之间间距的三种常见方法。根据你的需求和使用场景,可以选择其中一种来实现。
上一篇:并排的数字生成器