Css attribute selector for input type=“button” not

2019-01-14 13:19发布

I am working on a big form and it contains a lot of buttons all over the form, therefore I am trying to get working input[type="button"] in my main css file so it would catch all buttons with out having to add a class to every single one, for some reason this is not working on IE7, after checking on the web it says that IE7 should be supporting this.

Also it has to be type="button" and not type="submit" as not all buttons will submit the form.

Could anybody give a hint what am I doing wrong?

input[type="button"] {
    text-align:center;
}

I have also tried input[type=button]

8条回答
一纸荒年 Trace。
2楼-- · 2019-01-14 14:13

I've had no problems getting css statements like that working in IE7; IE6 is always the problem but I believe this CSS would work in there as well. So I don't think IE7 is the problem.

The first thing is that your CSS sample will only affect buttons, it will not affect submit buttons. But that's an easy fix; change your css to:

input[type="submit"], input[Type="button"]
{ text-align: center; }

Second, as Manolo Santos said, could you have another CSS statement that is overriding the text-align setting? A setting on just input elements? It's probably worth using a developer tool like Firebug or the developer components built into Chrome or IE8 to help find the CSS problem.

查看更多
贼婆χ
3楼-- · 2019-01-14 14:14

I was struggling getting input[type=button] selectors working in IE7 or IE8. The problem turned out to be that the HTML Pages were missing a "!DOCTYPE" declaration. Once I added

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Then everything worked fine. You can obviously use a different "!DOCTYPE" declaration to suit your requirements.

查看更多
登录 后发表回答