gpt4 book ai didi

css - 在 html 数字输入中居中文本

转载 作者:太空狗 更新时间:2023-10-29 15:24:07 26 4
gpt4 key购买 nike

我在 html 中输入了一个数字。我想将里面的文本(即输入)居中。我当然做了:

text-align: center;

哪种作品。问题是。当显示这些箭头时,文本现在居中。但是当箭头消失时,文本停留在相同的位置,现在当然不再是中心了。

Without arrows, the text does not appear centered.

最佳答案

您可以让微调按钮(箭头)始终显示:

input[type='number']::-webkit-inner-spin-button, 
input[type='number']::-webkit-outer-spin-button {
opacity: 1;
}

或者您可以让它们始终隐藏:

input[type='number']::-webkit-inner-spin-button, 
input[type='number']::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}

无论选择哪种方式,内容都将始终居中。

关于css - 在 html 数字输入中居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23715881/

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