如何在左边的选择列表中留一个空白

时间:2010-06-08 12:48:23

标签: html css

我试图在选择列表中留下左边的差距,但是它在firefox和safari中遇到的问题请给我源代码或我可以工作的任何参考链接...

我使用的代码:

<select style="padding:10px">
   <option>Male</option>
   <option>female</option>
   <option>other</option>
</select>

由于

是的,我想从左边缩进

1 个答案:

答案 0 :(得分:2)

也许你是在追求类似的东西:

<select style="padding: 0 0 0 10px">
   <option>Male</option>
   <option>female</option>
   <option>other</option>
</select>

jsFiddle example here

这就是你想要的吗?

修改

在Safari(适用于PC)you can style your select with text-indent:20px; Safari中进行一些测试后。也许你最好使用Brainfault select box replacement jQuery之类的东西,我刚刚在Safari(PC)中看过example并且jQuery工作得很好。

上次修改:

根据您的具体需求,请点击此CSS Browser selector,然后将其安装到您的页面上(只需将其下载到您的脚本文件夹中,然后将其复制并粘贴到您的头脑中:<script src="path-to-file/css_browser_selector.js" type="text/javascript"></script>

然后使用此HTML:

<select class="myselect">
   <option>Male</option>
   <option>female</option>
   <option>other</option>
</select>

然后使用这个CSS:

.gecko .myselect {
  padding: 0 0 0 20px;
}

.webkit .myselect {
text-indent:20px;
}

Isung这个jQuery选择插件,它会告诉FF使用填充和Safari(和chrome)来使用文本缩进。