HTML创建四个并排盒子 - 小间距布局
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
justify-content: space-between;
}
.box {
width: 100px;
height: 100px;
background-color: lightblue;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="container">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
</body>
</html>
在这个示例中,我们使用了CSS的`display: flex`来创建一个容器,将四个盒子元素放在一行上,并使用`justify-content: space-between`来让它们之间有间距。
<p>每个盒子都有<code>width: 100px</code>和<code>height: 100px</code>,背景颜色设置为<code>lightblue</code>,并添加了一个黑色边框。</p>
<p>你可以根据需要调整盒子的大小和颜色,以及调整容器的样式来满足你的要求。</p>
原文地址: https://www.cveoy.top/t/topic/qAri 著作权归作者所有。请勿转载和采集!