我无法更改select
的height
,所有浏览器都正常工作,但Safari不行,可能出了什么问题?我还尝试创建类.style select
,但没有起作用。
select {
width: 170px;
height: 25px;
}
试试添加这个:
-webkit-appearance: menulist-button;
-webkit-appearance: none;
并使用CSS hack来添加自己的下拉箭头图标。 - turkinator要在Safari中样式化
您还可以使用
line-height: 25px
这不会影响其他浏览器,但可以修复Safari中的此错误
height
或line-height
不起作用。 - Ralph David Abernathy@media screen and (-webkit-min-device-pixel-ratio:0) {
select {
-webkit-appearance: menulist-button !important;
line-height:24px !important;
}
}
这段代码可以确保在各种浏览器中元素的高度相同。
line-height: 20px;
至少在iPad上,选择框不会根据padding或line-height进行渲染,而是会根据给定的高度居中垂直地呈现该值。
select {
-webkit-appearance:menu-item; // or menulist-button
-moz-appearance:menu-item;
height:2.4em; // this must be calculated to match other input types
}
input[type="text"], select {
min-width:12em;
border-radius:5px;
}
现在唯一未解决的问题是背景,它是预定义和不可变的。
select, input {
font-size: 14px; //or whatever
height: 3em;
line-height: 3em;
padding: 0; //top and bottom must be 0
-webkit-appearance: none;
}
appearance:none
。 - Mladen Janjetovic@media screen and (-webkit-min-device-pixel-ratio:0) { select { -webkit-appearance: menulist-button !important; line-height:24px !important; } }
line-height
。直到我使用内联样式时,一切才开始起作用:
<select name="pickupsel" id="pickups" style="line-height:33px">
这是我在2022年解决这个问题的方法:
select {
background-color: inherit;
}
line-height
来改变它吗? - PRNDL Development Studios