简体   繁体   English

移动野生动物园:更改选择器视图的背景颜色(选择)

[英]mobile safari: change background color of picker view (select)

Mobile Safari uses a UIPickerView for <select> elements - I'd like to change the background color of it with CSS. Mobile Safari使用UIPickerView作为<select>元素 - 我想用CSS更改它的背景颜色。 As you can see in the screen shot below, it's very hard to read. 正如您在下面的屏幕截图中看到的,它很难阅读。 What you are looking at is the State <select> form element. 您正在查看的是State <select>表单元素。 Changing the text color or background color of the <select> element itself doesn't fix the problem. 更改<select>元素本身的文本颜色或背景颜色不能解决问题。

I thought it was related to a parent element's or its own background color - but I went up the line and changed every ancestor element's background color to white and the problem persisted. 我认为它与父元素或它自己的背景颜色有关 - 但我上线并将每个祖先元素的背景颜色更改为白色并且问题仍然存在。 Is there a prefixed style or trick to making this GUI legible? 有没有前缀的风格或技巧使这个GUI清晰可辨? Or maybe it's just a bug. 或许它只是一个错误。

EDIT: The gray behind the UIPickerView is filled in by mobile Safari, since the select is almost at the bottom of the page. 编辑: UIPickerView背后的灰色由移动Safari填充,因为选择几乎位于页面的底部。 Mobile Safari vertically centers the select above the UIPickerView and fills in the extra space below the page with the gray. Mobile Safari将选项垂直居中于UIPickerView上方,并用灰色填充页面下方的额外空间。 The question is, how does it determine to use that dark gray? 问题是,如何确定使用深灰色? I've tried changing the body text color, and background-color of every other element on the page to no avail. 我已经尝试更改正文文本颜色和页面上每个其他元素的背景颜色无济于事。

在此输入图像描述

Unfortunately, there isn't a way to do it. 不幸的是,没有办法做到这一点。 iOS Safari takes full control of styling select lists' internal contents. iOS Safari完全控制样式select列表的内部内容。 Here's a reference for verification: little link . 这是验证的参考: 小链接

One way to achieve this this would be to simulate the dropdown/select menu using JavaScript. 实现此目的的一种方法是使用JavaScript模拟下拉/选择菜单。

It's not very preferable, but if you absolutely require to change the default styling, then I'm afraid it's the only way to go; 这不是很好,但如果你绝对需要改变默认样式,那么恐怕这是唯一的出路; here's a demo that should give you an idea on how to do the simulation: another little link . 这是一个演示,应该让你知道如何进行模拟: 另一个小链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM