填充在选择列表中的Safari和IE中不起作用

May*_*yur 17 html css

有没有人知道为什么我的Safari没有选择列表中的填充?它在FF工作正常,请告诉我该怎么做.doctype有什么问题吗?

码:

<select style="padding-left:15px">
<option>male></option>
<option>female></option>
</select>
Run Code Online (Sandbox Code Playgroud)

我正在使用以下doctype;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Run Code Online (Sandbox Code Playgroud)

mVC*_*Chr 20

尽管W3规范不允许在选择框中禁用填充,但无论出于何种原因,webkit浏览器(Safari,Chrome)都不支持它.相反,您可以删除padding-left并使用text-indent相反的数量,将相同的金额添加到您的选择框中width.

从您评论中的示例:

<select id="sexID" name="user[sex]" 
        style="border:1px solid #C1272D;
               width:258px; // 243 + 15px
               text-indent:15px;
               height:25px;
               color:#808080;">
Run Code Online (Sandbox Code Playgroud)


小智 11

使用text-indent和line-height的组合来创建填充的错觉.在Safari中工作,也应该在IE中工作.

<select style="text-indent:15px; line-height:28px;">
 <option>male</option>
 <option>female</option>
</select>
Run Code Online (Sandbox Code Playgroud)


Nas*_*she 7

我知道这是一个老问题,但也许是一个更新的解决方案,帮助人们现在正在努力.

-webkit-appearance: initial;用填充添加到我的样式来解决问题.

-webkit-appearance: none; 在我的情况下没有帮助,因为它显示选择作为文本框.

经过测试......

Windows上的Safari v5.1.7(7534.57.2)

Mac上的Safari v8.0.6(10600.6.3)

iPhone 6