如何在 IE 中隐藏 CSS 活动图像

发布于 2024-11-09 12:40:33 字数 1218 浏览 0 评论 0原文

我有一个输入框,它是我的登录功能的一部分。我正在 css 中显示图像,然后单击框 (:active),图像消失,允许用户输入信息。我使用图像的原因是因为文本密码显示*

这在除 IE 之外的所有浏览器中都可以正常工作。任何人都可以帮忙。

HTML:

<form class="additemsignupformlivregister">
  <div class="logininputdiv">
    <input type="text" class="filterinput clearField">
  </div>
  <div class="logininputdiv">
     <input type="password" class="filterinputpassword clearField">
  </div>
 </form>

这是 CSS:

.filterinput {
-moz-border-radius:3px;
border-radius:3px;
-webkit-border-radius:3px;
border: 1px solid #D0D0D0;
box-shadow: 0 0 2px #9B9B9C inset;
color: #9b9b9c;
font-family: arial;
font-size: 12px;
height: 30px;
line-height: 30px;
margin-bottom: 10px;
margin-left: -3px;
padding-left: 5px;
padding-right: 10px;
width: 170px;
background-image: url("../images/enteremail.png");
background-repeat: no-repeat;
}

同样,单击输入字段,图像会在 Firefox、Chrome 和 Safari 中消失,但不会在 IE 中消失。谢谢。

.filterinput:focus{
box-shadow:0 0 2px #000000 inset;
-moz-box-shadow:0 0 2px #000000 inset;
-webkit-box-shadow:0 0 2px #000000 inset;
color: #000000;
background: none;
}

I have an input box that is part of my log in functionality. I am displaying an image in css and onclick on the box (:active), the image disappears allowing the user to type in the information. The reason I am using an image is because of the text password displaying *.

This works fine in all browsers except IE. Can anyone help.

HTML:

<form class="additemsignupformlivregister">
  <div class="logininputdiv">
    <input type="text" class="filterinput clearField">
  </div>
  <div class="logininputdiv">
     <input type="password" class="filterinputpassword clearField">
  </div>
 </form>

Here is the CSS:

.filterinput {
-moz-border-radius:3px;
border-radius:3px;
-webkit-border-radius:3px;
border: 1px solid #D0D0D0;
box-shadow: 0 0 2px #9B9B9C inset;
color: #9b9b9c;
font-family: arial;
font-size: 12px;
height: 30px;
line-height: 30px;
margin-bottom: 10px;
margin-left: -3px;
padding-left: 5px;
padding-right: 10px;
width: 170px;
background-image: url("../images/enteremail.png");
background-repeat: no-repeat;
}

Again, onclick on the input field the image disappears in Firefox, Chrome, and Safari but not IE. Thanks.

.filterinput:focus{
box-shadow:0 0 2px #000000 inset;
-moz-box-shadow:0 0 2px #000000 inset;
-webkit-box-shadow:0 0 2px #000000 inset;
color: #000000;
background: none;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生共白头 2024-11-16 12:40:33

IE 5.5、6 和 7 不支持 :focus css 选择器

http://reference.sitepoint.com/css/pseudoclass-focus

将 id 添加到您的密码输入中

<input id="password" type="password" class="filterinputpassword clearField">

将其添加到您的 head 标记中

<!--[if lte IE 7]>
<script type="text/javascript">
    var password = document.getElementById("password");
    var defaultClasses = this.className;
    password.onfocus = function () {
        this.className = defaultClasses + " focus";
    }
    password.onblur = function () {
        this.className = defaultClasses;
    }
</script>
<![endif]-->

并将其添加到您的 CSS 中:

.filterinput:focus, .filterinput.focus { /* same as before */ }

使用 jQuery 你只需要这样做:

<!--[if lte IE 7]>
<script type="text/javascript">
    $(function(){
        $("input:password").bind("focus blur", function() { 
            $(this).toggleClass("focus"); 
        });
    });
</script>
<![endif]-->

仅将其包装起来,以便其他正常工作的浏览器不会有此开销。

您仍然需要定义 css .filterinput.focus 类。

IE 5.5, 6, and 7 do not support the :focus css selector

http://reference.sitepoint.com/css/pseudoclass-focus

Add an id to your password input

<input id="password" type="password" class="filterinputpassword clearField">

Add this in your head tag

<!--[if lte IE 7]>
<script type="text/javascript">
    var password = document.getElementById("password");
    var defaultClasses = this.className;
    password.onfocus = function () {
        this.className = defaultClasses + " focus";
    }
    password.onblur = function () {
        this.className = defaultClasses;
    }
</script>
<![endif]-->

And this to your CSS:

.filterinput:focus, .filterinput.focus { /* same as before */ }

Using jQuery you would only need to do this:

<!--[if lte IE 7]>
<script type="text/javascript">
    $(function(){
        $("input:password").bind("focus blur", function() { 
            $(this).toggleClass("focus"); 
        });
    });
</script>
<![endif]-->

Only wrapped that so that other browsers that work properly don't have this overhead.

You will still need the css .filterinput.focus class defined.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文