背景
我正在使用 jQuery、jQuery Validation 和 jQuery Autocomplete 开发一个网站。我正在开发一个表单,它使用验证来确保一些表单元素有效,自动完成以填充文本框,然后使用 AJAX 动态替换表单。该表单包含几个表单元素,包括一些下拉列表框 (...)。列表框使用 CSS3 设置样式(使用 Modernizr 实现向后兼容性)。
问题
问题出在 Internet Explorer 上。我正在用 IE9 进行测试,但我认为它在 IE7 或 IE8 中也不起作用。有两个下拉选择框,都出现故障。当用户单击下拉箭头以显示 optional 列表时,一旦鼠标移到列表上进行选择,该列表就会消失,就好像用户单击了鼠标(但没有进行选择)一样。
其他说明:-
- 这些框在所有其他浏览器中都能正常运行。
- 这些框使用 CSS3 设置样式。
- 如果我切换兼容性 View ,盒子会正常运行,尽管它们看起来很糟糕。
代码
HTML
<form name="form1" action="#" method="post" id="form1">
<fieldset>
<label for = "radio1">
<input type="radio" id="radio1" name="type" value="1" checked = "checked" />
Sell</label>
<label for = "radio2">
<input type="radio" id="radio2" name="type" value="2" />
Buy</label>
</fieldset>
<label>Address or zipcode</label>
<input name="address" id="address" type="text" size="40" placeholder="Address or zipcode" class="ui-helper-clearfix" />
<label>Second Option</label>
<select name="first_option" id="first_option">
<option value="" disabled="disabled">Select Option</option>
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
<label>Second Option</label>
<select name="second_option" id="second_option">
<option value="" disabled="disabled">Select Option</option>
<option value="1">Option 1</option>
<option value="2">Option 1</option>
<option value="3">Option 1</option>
<option value="4">Option 1</option>
<option value="5">Option 1</option>
<option value="6">Option 1</option>
<option value="7">Option 1</option>
<option value="8">Option 1</option>
<option value="9">Option 1</option>
</select>
<input name="submitbutton" type="submit" value="Submit" />
</form>
CSS
form { margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; }
label { cursor: pointer; }
label{display:none;font: 100 italic 1.2em/1em "museo-sans";}
label[for=radio1], label[for=radio2]{display: inline-block;margin-right: 1em;padding: 0.7em 0;}
input, select, input[type=placeholder]{color:#666}
select, input, textarea, datalist{ outline: none;font:100 italic 1.2em/1em "museo-sans";margin:0 0 0.5em}
datalist, select, input[type=text], input[type=email], input[type=tel], textarea{padding: 2%;-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;border: 1px solid #CCC;width: 96%;background:#fff}
select{width:100%}
input[type=submit], input[type=button], a.button, button {
color: #fff;border: none;width:100%;text-align:center;padding: 0.8em 0;font-size:1.3em;font-weight:700;font-style:normal;text-transform:uppercase;background: #ed4136;border: none;
-moz-border-radius: 6px;-webkit-border-radius: 6px;border-radius: 6px;cursor:pointer;margin-bottom:0}
问题
有谁知道这是脚本错误还是 CSS 错误?我试过在网上搜索类似的问题,但没有任何线索。深入了解哪些事情可能会导致该错误会很好。
我有预感这是一个 CSS 错误,因为兼容性 View 使错误消失了。如果有人验证我是对还是错并提供一些见解,那就太好了。
如果有人对此有任何信息或建议的修复,我将非常感激。
最佳答案
我了解到 position:relative;
涵盖了很多 ie 浏览器的错误。
关于jquery - 选择框在 Internet Explorer 中不起作用/消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8242275/