Buttons too tall on Firefox

痴心易碎 提交于 2019-11-29 01:23:33

问题


I've got a problem unique to Firefox. I'm trying to style links and buttons to look exactly the same. On every browser except Firefox, this works as desired. On Firefox, the height of the button's content is 18 pixels, compared to 15 pixels for the link. On Chrome, Safari, and Internet Explorer, they're both the proper 15 pixels tall. Why is this?

Here's a demo on jsFiddle of the problem. Here's the result I get on Chrome:

and here's the Firefox result:

I've tried changing the height manually in CSS, but that doesn't entirely work and breaks the layout on other browsers. Setting -moz-appearance: none does nothing, but then again, it usually doesn't.

Here's a full detail of my attempt, too, and what it's going to be used for.

Has anyone come across this problem before? How can I equalize the height across all browsers?


回答1:


Found another user who used this:

input::-moz-focus-inner /*Remove button padding in FF*/
{ 
    border: 0;
    padding: 0;
}

http://jsfiddle.net/MCAllinder/dehda/2/




回答2:


I've found a complete solution and wrote about it here:

http://davidwalsh.name/firefox-buttons

input::-moz-focus-inner { 
    border: 0; 
    padding: 0; 
    margin-top:-2px; 
    margin-bottom: -2px; 
}

You need to modify the margin-top and margin-bottom to match your other buttons



来源:https://stackoverflow.com/questions/8859908/buttons-too-tall-on-firefox

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!