在IE浏览器中的select标记选项之间添加空格 [英] Adding space between options of select tag in IE browser

查看:334
本文介绍了在IE浏览器中的select标记选项之间添加空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在IE浏览器中的select元素的2个选项之间添加一个空格.我的代码使用我为select元素编写的CSS在Firefox和Chrome中工作.但是,样式不适用于IE.这是 select 元素的CSS,例如:

I want to add a space in between 2 options of a select element in IE browser. My code works in Firefox and Chrome, using CSS I wrote for the select element. However, the styles are not applied in IE. This is the CSS for the select element is like:

.branchDropdown { border: 1px solid #999999; width: 155px; } 

以及 option 元素:

.branchDropdown option { cursor: pointer; margin-top: 10px; }

推荐答案

您无法在Internet Explorer中使用大多数属性设置<option>元素的样式.它们从Windows操作系统继承样式,背景颜色和字体颜色除外.这是MSDN页面上<option>的报价:

You cannot style <option> elements in Internet Explorer with most properties. They inherit the style from the Windows operating system, except for the background and font colours. Here's a quote from the MSDN page for <option>:

除了背景色和颜色外,将忽略通过style对象为option元素应用的样式设置.此外,直接应用于各个选项的样式设置会覆盖整体应用于包含的select元素的样式设置.

Except for background-color and color, style settings applied through the style object for the option element are ignored. In addition, style settings applied directly to individual options override those applied to the containing select element as a whole.

http://msdn.microsoft .com/en-us/library/ie/ms535877(v = vs.85).aspx

要创建一致的外观,唯一的选择是使用JavaScript呈现自定义元素,以替换页面上的默认选择元素.

To create a consistent appearance, your only other option is to use JavaScript to render a custom element that replaces the default select element on your page.

这篇关于在IE浏览器中的select标记选项之间添加空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆