开发者

Remove all formatting from a single tag

开发者 https://www.devze.com 2023-03-10 06:01 出处:网络
I am using a wordpress plugin which applies some CSS formatting to all input tags. I\'d like my submit button to not have these and to u开发者_运维问答se the default css settings (applied by browser)

I am using a wordpress plugin which applies some CSS formatting to all input tags. I'd like my submit button to not have these and to u开发者_运维问答se the default css settings (applied by browser) instead.

How can I

  1. Apply the CSS to all input tags other than submit button (input type="submit") OR
  2. Remove all custom CSS from submit button?

Thanks.


In CSS3 you can target all elements but x with:

*:not(x) {
    // some css
}

See here.

I'm not sure it's possible with CSS2 (without using javascript, as Jeff points out in the comments).


For item #1 you can just identify the types of input that are not submit, ala:

input[type=text], input[type=password],input[type=checkbox], input[type=radio],
textarea, select {
    background-color:#fff;
    border: 1px solid #bbb;
}

For item #2 you would need to assign and id to the submit button and then override all the styles it's inheriting that you want removed.


Using jquery, something like the following should work:

$('input[type=submit]').removeAttr("class")

This was quickly cobbled together, not tested it.


This can be problematic for cross browser reasons.

input[type="submit"] { margin:0; padding:0; background:#fff;border:.... }

Would target just submit inputs, however it's not compatible with IE6.

input:not([type="submit"]) {...} 

Targets all inputs that aren't type text, but they're not compatible with IE6, 7 or 8.

If you're concerned about IE6, you're going to have to manually override the class in your style.css

Check out the compatibility matrix here: http://www.quirksmode.org/css/contents.html#CSS3

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号