gpt4 book ai didi

css - 在 Safari 中使用 CSS 选择 html 中的居中文本

转载 作者:行者123 更新时间:2023-12-05 07:13:21 24 4
gpt4 key购买 nike

我正在尝试使用 CSS 将文本居中放置在 HTML 选择表单中,它适用于除 Safari 之外的所有浏览器,我尝试使用 text-align: -webkit-center; 但它没有不工作。

select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}

label.cw-select {
display: inline-block;
position: relative;
}

.cw-select select {
background: #4d4d4d;
border-radius: 0.3rem;
border: 1px solid #212121;
color: white;
display: inline-block;
height: 30px;
line-height: 1.2;
margin: 0;
min-width: 48px;
outline: none;
padding: 4px 20px 3px 0px;
text-align: center;
text-align: -webkit-center;
text-align: -moz-center;
}

.cw-select:after {
background: #1d1d1d;
border-top-right-radius: 0.3rem;
border-bottom-right-radius: 0.3rem;
bottom: 0;
color: white;
content: "▼";
font-size: 60%;
line-height: 30px;
padding: 0 6px;
pointer-events: none;
position: absolute;
right: 0;
top: 0;
}
<label class="cw-select">
<select name="numberOfPlayers" form="numberOfPlayers">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</label>

Safari

enter image description here

其他

enter image description here

最佳答案

我认为左填充设置为 0。请检查此代码。

.cw-select select {
background: #4d4d4d;
border-radius: 0.3rem;
border: 1px solid #212121;
color: white;
display: inline-block;
height: 30px;
line-height: 1.2;
margin: 0;
min-width: 48px;
outline: none;
padding: 4px 20px 3px 10px; // instead of 4px 20px 3px 0;
text-align: center;
text-align: -webkit-center;
text-align: -moz-center;
}

关于css - 在 Safari 中使用 CSS 选择 html 中的居中文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60186815/

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