开发者

How to reset default button style in Firefox 4 +

In firefox 3.6 you could use ::-moz-focus-inner {border:0;padding:0;margin:0;} to remove thos开发者_开发百科e default margins and paddings forms.css added.

How can I reset this in Firefox 4? I've been searching for any .css files inside the install directory that could add styles to my button but can't find any for ff4 - the button still gets that annoying 1px top padding that won't allow the text to align to vertical middle.

http://easwee.net/other/FF_problem.gif

EDIT: I use a reset stylesheet so no need to reset styles. It's a browser stylesheet that's messing here.


I actually found the solution myself.

In your url field type: resource://gre-resources/forms.css - this will open forms.css for FF4 - and search for the following selector

button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner,
input[type="file"] > input[type="button"]::-moz-focus-inner

Now just put that in your main stylesheet like:

button::-moz-focus-inner,
input[type="reset"]::-moz-focus-inner,
input[type="button"]::-moz-focus-inner,
input[type="submit"]::-moz-focus-inner,
input[type="file"] > input[type="button"]::-moz-focus-inner {border:0;padding:0;margin:0;}

It shouldn't be overriding your css anymore. Also note that if you haven't defined any font style for your inputs FF won't inherit body font styling.


try setting it's values to undefined (border:undefined etc). not sure here, but it worked for me when I had a similiar problem.


Twitter Bootstrap does it like this in its reset.less (which is a more barebones version of normalize.css):

button::-moz-focus-inner,
input::-moz-focus-inner { // Inner padding and border oddities in FF3/4
  padding: 0;
  border: 0;
}

As an aside, Bootstrap's reset.less is probably a more reliable and perennial solution to achieve form cross-browser-ness than maintaining your own rules. It's much more complete than Meyer's reset.css, but more minimalist than normalize.css.


just use a css reset stylesheet, that will reset all the default css for most browsers

http://meyerweb.com/eric/tools/css/reset/

or read this stackeoverflow Q&A

https://stackoverflow.com/questions/116754/best-css-reset

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜