2017-09-26 63 views
1

我无法获取在Firefox中显示的选择下拉式输入的占位符文本。它在IE和Chrome中运行正常。添加占位符文本以选择输入 - firefox

我的CSS:

select option:first-child {color: #666666;display: none;} 

我的HTML:

<select name="exp_date" id="exp_date" style="width: 50%; display: inline; border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-right: none; cursor: pointer;" class="form-control" title="Enter Expiration Date - Month"> 
    <option selected="" value="" label="Month"> 
    </option><option value="01" label="1">1 
    </option><option value="02" label="2">2 
    </option><option value="03" label="3">3 
    ... 
</select> 

它的外观镀铬 enter image description here

它的外观在Firefox enter image description here

+0

请发表[MCVE] – j08691

+0

能否请您共享代码,这将有助于了解编辑添加代码问题 –

+0

。对不起, – JEP

回答

1

您可以添加在下面的格式月份值选项它将作为占位符,它会在Chrome worki以及Firefox浏览器。

<select name="exp_date" id="exp_date" style="width: 50%; display: inline; border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-right: none; cursor: pointer;" class="form-control" title="Enter Expiration Date - Month"> 
     <option value="" selected disabled hidden>Month</option> 
     </option><option value="01" label="1">1 
     </option><option value="02" label="2">2 
     </option><option value="03" label="3">3 
     ... 
    </select> 
+0

感谢deja和mahip_j。你的回答都很完美! – JEP

0

我相信select上的占位符不支持Mozilla。相反,您可以添加一个带有选定属性的空值选项。例如,

<option selected="selected" disabled hidden>Month</option> 
+0

上打开,感谢deja和mahip_j。您的答复都完美奏效 – JEP