<select> with size attribute: iPhone renders blank

后端 未结 4 1057
半阙折子戏
半阙折子戏 2021-02-13 05:15

When rendering a select dropdown as below, the iPhone renders it blank. How can I fix this?


                        
    
提交评论

  • 2021-02-13 05:45

    If you need to display one of the options, use the following: HTML selected Attribute

    enter image description here



    Your webpage at firefox:

    enter image description here

    0 讨论(0)
  • 2021-02-13 06:02

    Looks like there is no standard way to do it, based on content of other topics on stack overflow:

    • Safari Mobile Multi-Line <Select> aka GWT Multi-Line ListBox
    • jquery plugin to convert a <select size="10"> to a usable list on Safari mobile (iOS)

    But author of the second topic wrote a plugin that emulates that behavior: https://github.com/redhotsly/safarimobile-multiline-select

    0 讨论(0)
  • 2021-02-13 06:05

    It appears that people here might not be fully understanding the issue. The problem is that the iOS browser will not render the label for the unselectable first field, which would typically be a "Please select ..." type indicator. If it is not selected, iOS renders it as blank. This is not desirable, because there are choices for the user to make, but the field appears as blank.

    You cannot also set it programatically selected to get the "Please select" to display, because if the field is required, the form validation no longer works, as the browser considers the first field as selected, even though it is flagged as unselectable.

    The "Bug" is that iOS browser will not display the label for the first field, when it is set as unselectable.

    0 讨论(0)
  • 提交回复
    热议问题