我正在设计一个严格的DOCTYPE的HTML页面,并在我的页面中有一个表单元素。css悬停在IE中的元素问题
我想要做的是当鼠标触摸我的表单时更改输入框的背景颜色。我已经使用css:hover选择器在表单标签上完成了这项工作,但问题是IE只能理解悬停在“a”标签上!
我GOOGLE了我的问题,我发现是:使用HTC文件
- ;
- 使用javascript在元素上创建悬停类;
- 创建一个大的“a”标签并将其中的所有元素;
但我不想做任何这些解决方案!
在IE中解决这个问题没有更好的办法吗?
我的HTML代码:
<form id="footer-search-form" title="Search" action="#action">
<fieldset>
<input type="text" class="footer-search-input" id="q" name="Search"></input>
<input type="button" class="footer-search-button" title="Search" value="Search"></input>
</fieldset>
</form>
我的CSS代码:
#footer-search-form:hover .footer-search-button { background-color: #fff; }
#footer-search-form:hover .footer-search-input { background-color: #fff; }
更新:和搜索我做到了用JS小时后:
onmouseover="this.setAttribute(document.all?'className':'class','footer-search-hovered');" onmouseout="this.removeAttribute(document.all?'className':'class','footer-search-hovered');"
和
.footer-search-hovered .footer-search-input, .footer-search-hovered .footer-search-button { background-color: #fff !important; } /* For IE6 compatibility */
我恨它,但似乎也没有更好的办法...
为什么你不想使用'.htc'修复? http://peterned.home.xs4all.nl/csshover.html – thirtydot 2011-12-31 00:26:00
我有一些'.htc'修复不好的经历。大多数时候他们通过创建另一个复杂的问题来解决一个简单的问题! – 2011-12-31 01:00:56