gpt4 book ai didi

html - Float :left div 内的居中对齐按钮

转载 作者:行者123 更新时间:2023-11-28 07:29:05 27 4
gpt4 key购买 nike

我正在尝试让 3 个左对齐的 float 。 Here是执行此操作的以下 JFiddle。

div { height: 45px; }
div.side {
background-color: skyblue;
width: 72px;
float: left;
}
div#range {
background-color: tomato;
width: 216px;
float: left;
}
span {
width:100%;
text-align: center;
display: block;
margin: 3px auto;
/* background-color: gold; */
}
<div id="start" class="side">
<button type="button">Click Me!</button>
</div>
<div id="range"></div>
<div id="end" class="side">
<button type="button">Click Me!</button>
</div>

我现在要做的是将名为 side 的 div 中的按钮居中对齐。我试过使用另一个将文本对齐设置为居中的 div,但这不起作用。

最佳答案

应用于 .side div 的 text-align: center 应该可以解决问题,因为 button 元素默认是内联的。请注意,我更改了 .side 的宽度以使居中效果明显:https://jsfiddle.net/021gu79c/1/ .

CSS:

div.side {
background-color: skyblue;
width: 120px;
float: left;
text-align: center;
line-height: 45px;
}

关于html - Float :left div 内的居中对齐按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31642987/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com