How do I put a space character before option text

2019-01-09 08:44发布

In a drop down list, I need to add spaces in front of the options in the list. I am trying

<select>
<option>&#32;&#32;Sample</option>
</select>

for adding two spaces but it displays no spaces. How can I add spaces before option texts?

14条回答
叛逆
2楼-- · 2019-01-09 09:34

@Brian

I'm nearly certain you can accomplish this with CSS padding, as well. Then you won't be married to the space characters being hard-coded into all of your tags.

Good thinking - but unfortunately it doesn't work in (everyone's favourite browser...) IE7 :-(

Here's some code that will work in Firefox (and I assume Op/Saf).

<select>
    <option style="padding-left: 0px;">Blah</option>
        <option style="padding-left: 5px;">Blah</option>
            <option style="padding-left: 10px;">Blah</option>
    <option style="padding-left: 0px;">Blah</option>
        <option style="padding-left: 5px;">Blah</option>
</select>
查看更多
forever°为你锁心
3楼-- · 2019-01-09 09:39

Just use char 255 (type Alt+2+5+5 on your numeric keypad) with a monospace font like Courier New.

查看更多
登录 后发表回答