css 中心 3 个内联块按钮

问题描述 投票:0回答:1

我有 3 个按钮

<button class="align" id="decrease">decrease</button> <button class="align" id="reset">reset</button> <button class="align" id="increase">increase</button>
和一个将一些按钮居中的 css 类
.align{ position: absolute; right: 50%; display: inline-block; }
,但最终结果看起来像这样

有什么方法可以让它们居中,同时保持它们分开,还是我必须为它们分配一个单独的类?

我原以为它们会因为

display: inline-block;
而分开,但它们只是堆叠在一起。我试过给他们保证金,但没有成功。

html css button
1个回答
0
投票

要使按钮居中并保持它们分开,您可以对 CSS 进行轻微调整。您可以应用 text-align: center;到父容器,然后可以设置display: inline-block;在按钮上。

仅供参考:快速谷歌搜索/chatgpt 请求可以解决你这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.