Chrome 输入类型=“数字” CSS 样式

发布于 2024-10-11 08:51:24 字数 247 浏览 1 评论 0 原文

我有以下输入 type="number":

<input id="myid" type="number" name="input" min="0" max="100" step="1" value="0">

在 Chrome 中,只有您可以看到 2 个增加或减少值的箭头。有没有办法设置这些控件的样式。像这样的东西:

#myid::-webkit-

I have the following input type="number":

<input id="myid" type="number" name="input" min="0" max="100" step="1" value="0">

In Chrome only you can see 2 arrows that increase or decrease the value. Is there a way to style those controls. Something like:

#myid::-webkit-

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

快乐很简单 2024-10-18 08:51:24

我自己也遇到了这个问题。实际上,我试图摆脱它们,但是,链接的SO问题中的相同规则仍然应该适用于改变外观,因为出色地。我在另一个SO问题中找到了解决方案。看看已接受的答案,它就像一个魅力。

I just ran into this myself. Actually, I was trying to get rid of them, however, the same rules in the the linked SO question still should apply for altering appearance as well. I found the solution in another SO question. Look at the accepted answer, it works like a charm.

拔了角的鹿 2024-10-18 08:51:24

我似乎找不到数字输入的默认箭头样式。
希望这有帮助。
以下是数字输入元素中找到的所有样式的列表(使用 chromes 检查模式找到):

1.  -webkit-appearance: textfield;
2.  -webkit-rtl-ordering: logical;
3.  -webkit-user-select: text;
4.  background-color: white;
5.  border-bottom-style: inset;
6.  border-bottom-width: 2px;
7.  border-left-style: inset;
8.  border-left-width: 2px;
9.  border-right-style: inset;
10. border-right-width: 2px;
11. border-top-style: inset;
12. border-top-width: 2px;
13. color: black;
14. cursor: auto;
15. display: inline-block;
16. font-family: Arial;
17. font-size: 13px;
18. font-style: normal;
19. font-variant: normal;
20. font-weight: normal;
21. height: 16px;
22. letter-spacing: normal;
23. line-height: normal;
24. margin-bottom: 2px;
25. margin-left: 2px;
26. margin-right: 2px;
27. margin-top: 2px;
28. padding-bottom: 1px;
29. padding-left: 0px;
30. padding-right: 0px;
31. padding-top: 1px;
32. text-align: -webkit-auto;
33. text-indent: 0px;
34. text-shadow: none;
35. text-transform: none;
36. width: 151px;
37. word-spacing: 0px;
Styles
________________________________________

element.style {
}
Matched CSS Rules
user agent stylesheet
input:not([type]), input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"] {
1.  padding: 1px 0px;
}
user agent stylesheet
input, input[type="password"], input[type="search"], isindex {
1.  -webkit-appearance: textfield;
2.  padding: 1px;
3.  background-color: white;
4.  border: 2px inset;
5.  -webkit-rtl-ordering: logical;
6.  -webkit-user-select: text;
7.  cursor: auto;
}
user agent stylesheet
input, textarea, keygen, select, button, isindex, datagrid {
1.  margin: 0em;
2.  font: -webkit-small-control;
3.  color: initial;
4.  letter-spacing: normal;
5.  word-spacing: normal;
6.  line-height: normal;
7.  text-transform: none;
8.  text-indent: 0px;
9.  text-shadow: none;
10. display: inline-block;
11. text-align: -webkit-auto;
}
Pseudo ::-webkit-input-placeholder element
user agent stylesheet
input::-webkit-input-placeholder, isindex::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
1.  color: darkGray;
}
Pseudo ::-webkit-media-controls-volume-slider-container element
user agent stylesheet
input::-webkit-input-speech-button {
1.  -webkit-appearance: -webkit-input-speech-button;
2.  display: inline-block;
}
Pseudo ::-webkit-media-controls-current-time-display element
user agent stylesheet
input::-webkit-inner-spin-button {
1.  -webkit-appearance: inner-spin-button;
2.  display: inline-block;
3.  -webkit-user-select: none;
}
Pseudo ::-webkit-media-controls-time-remaining-display element
user agent stylesheet
input::-webkit-outer-spin-button {
1.  margin: 0px;
}
user agent stylesheet
input::-webkit-outer-spin-button {
1.  -webkit-appearance: outer-spin-button;
2.  display: inline-block;
3.  margin-left: 2px;
4.  -webkit-user-select: none;
}

I can't seem to find the number input's default arrow styles.
Hope this helps.
Heres a list of all the styles found in the number input element (found using chromes inspect mode):

1.  -webkit-appearance: textfield;
2.  -webkit-rtl-ordering: logical;
3.  -webkit-user-select: text;
4.  background-color: white;
5.  border-bottom-style: inset;
6.  border-bottom-width: 2px;
7.  border-left-style: inset;
8.  border-left-width: 2px;
9.  border-right-style: inset;
10. border-right-width: 2px;
11. border-top-style: inset;
12. border-top-width: 2px;
13. color: black;
14. cursor: auto;
15. display: inline-block;
16. font-family: Arial;
17. font-size: 13px;
18. font-style: normal;
19. font-variant: normal;
20. font-weight: normal;
21. height: 16px;
22. letter-spacing: normal;
23. line-height: normal;
24. margin-bottom: 2px;
25. margin-left: 2px;
26. margin-right: 2px;
27. margin-top: 2px;
28. padding-bottom: 1px;
29. padding-left: 0px;
30. padding-right: 0px;
31. padding-top: 1px;
32. text-align: -webkit-auto;
33. text-indent: 0px;
34. text-shadow: none;
35. text-transform: none;
36. width: 151px;
37. word-spacing: 0px;
Styles
________________________________________

element.style {
}
Matched CSS Rules
user agent stylesheet
input:not([type]), input[type="color"], input[type="date"], input[type="datetime"], input[type="datetime-local"], input[type="email"], input[type="month"], input[type="number"], input[type="password"], input[type="tel"], input[type="text"], input[type="time"], input[type="url"], input[type="week"] {
1.  padding: 1px 0px;
}
user agent stylesheet
input, input[type="password"], input[type="search"], isindex {
1.  -webkit-appearance: textfield;
2.  padding: 1px;
3.  background-color: white;
4.  border: 2px inset;
5.  -webkit-rtl-ordering: logical;
6.  -webkit-user-select: text;
7.  cursor: auto;
}
user agent stylesheet
input, textarea, keygen, select, button, isindex, datagrid {
1.  margin: 0em;
2.  font: -webkit-small-control;
3.  color: initial;
4.  letter-spacing: normal;
5.  word-spacing: normal;
6.  line-height: normal;
7.  text-transform: none;
8.  text-indent: 0px;
9.  text-shadow: none;
10. display: inline-block;
11. text-align: -webkit-auto;
}
Pseudo ::-webkit-input-placeholder element
user agent stylesheet
input::-webkit-input-placeholder, isindex::-webkit-input-placeholder, textarea::-webkit-input-placeholder {
1.  color: darkGray;
}
Pseudo ::-webkit-media-controls-volume-slider-container element
user agent stylesheet
input::-webkit-input-speech-button {
1.  -webkit-appearance: -webkit-input-speech-button;
2.  display: inline-block;
}
Pseudo ::-webkit-media-controls-current-time-display element
user agent stylesheet
input::-webkit-inner-spin-button {
1.  -webkit-appearance: inner-spin-button;
2.  display: inline-block;
3.  -webkit-user-select: none;
}
Pseudo ::-webkit-media-controls-time-remaining-display element
user agent stylesheet
input::-webkit-outer-spin-button {
1.  margin: 0px;
}
user agent stylesheet
input::-webkit-outer-spin-button {
1.  -webkit-appearance: outer-spin-button;
2.  display: inline-block;
3.  margin-left: 2px;
4.  -webkit-user-select: none;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文