Preserve whitespace in html select element options using “white-space: pre” NOT working

后端 未结 2 811
悲哀的现实
悲哀的现实 2020-12-20 14:05

My problem comes from HTML dropdown select not able to preserve multiple consecutive whitespaces in its options. Here is a sample testcase and outcome. The \"white-space:pre

2条回答
  •  一整个雨季
    2020-12-20 14:19

    Form inputs usually map to their relevant native OS controls so they can be hard to style. The usual workaround to keep whitespace from collapsing into 1 space in s is to use   instead of usual spaces.

    eg. one of your options would be:

    
    

    For more custom appearance, you would hide the real select element completely and replace it with custom markup and javascript.

提交回复
热议问题