Css attribute selector for inputs not working in I

2019-02-25 07:07发布

I have the following css code working in Firefox/Chrome but not in IE8

input[type='text']
{
    float: right;
    width: 170px;
}

If I remove the attribute selector, it works in IE but it applies to all the inputs, which I dont want.

input
{
    float: right;
    width: 170px;
}

I thought attribute selectors were supported in IE8, so I don't know what the problem is. It is not a matter of the code inside the input, from the moment I use the attribute selector, that css rule will not work whatever code is inside.

EDIT: Css rules for input[type="button"] and input[type="submit"] DO work, but for input[type="text"] DO NOT work. I'm really confused right now.

标签: html css input
3条回答
成全新的幸福
2楼-- · 2019-02-25 07:32

Go to this Question

Used to jquery

As like this

$('input[type="text"]').css({float: 'right'});
查看更多
爷的心禁止访问
3楼-- · 2019-02-25 07:35

IE7 and IE8 support attribute selectors only if a !DOCTYPE is specified. Attribute selection is NOT supported in IE6 and lower.

查看更多
Luminary・发光体
4楼-- · 2019-02-25 07:49

According to http://reference.sitepoint.com/css/css3attributeselectors#compatibilitysection attribute selectors are quite buggy in IE8

You might want to try just using classes on those input fields you want to select

查看更多
登录 后发表回答