CSS代码:将带button和title类的按钮在div中垂直水平居中并等距排列
可以使用以下CSS代码实现:
#title {
display: flex;
align-items: center;
justify-content: center;
}
.button {
width: 15%;
margin: 0 5%;
}
.title {
width: 15%;
margin: 0 5%;
}
在HTML中,你可以这样使用:
<div id="title">
<button class="button">按钮1</button>
<button class="button">按钮2</button>
<button class="button">按钮3</button>
<button class="button">按钮4</button>
<button class="button">按钮5</button>
<button class="button">按钮6</button>
<button class="title">标题</button>
</div>
这样,按钮和标题会被放置在垂直方向的中间,水平位置从40%开始,每个按钮占用15%的空间,中间隔5%的空间。
原文地址: https://www.cveoy.top/t/topic/qvEt 著作权归作者所有。请勿转载和采集!