如何获取CSS悬停事件在IE中触发时鼠标是在输入元素的文本? [英] How to get CSS hover event to trigger in IE when mouse is over text of input element?

查看:115
本文介绍了如何获取CSS悬停事件在IE中触发时鼠标是在输入元素的文本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用IE下面的HTML,如果我将鼠标悬停在测试一词上,我无法得到输入的背景更改为红色。但是,如果我将鼠标悬停在单词Test右侧的区域,但仍然在输入元素的边界内,则会变为红色。这在Firefox或Chrome中不会发生。

Using IE with the HTML below, I can't get the input's background to change to red if I hover my mouse immediately over the word "Test". It does, however, change to red if I hover over the area to the right of the word "Test" but still within the bounds of the input element. This doesn't happen in Firefox or Chrome. What is the proper way to define my styles to get this to work correctly in IE?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title></title>
    <style type="text/css">
        input { border: 0px; margin:0; padding:0; }
        input:hover { background: red }
    </style>
  </head>
  <body>
    <input type="text" value="Test" />
  </body>
</html>


推荐答案

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ru" lang="ru">

这将启用:hover 支持IE的资料

This will enable :hover support and other stuff for IE

这篇关于如何获取CSS悬停事件在IE中触发时鼠标是在输入元素的文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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