简体   繁体   English

在IE按钮中删除额外的填充

[英]Remove extra padding in IE button

In my website, there are lots of buttons. 在我的网站上,有很多按钮。 When viewing in Chrome, the button width just fit on the dynamic button text, but in IE, I can see extra padding are produced on both left and right... 在Chrome中查看时,按钮宽度恰好适合动态按钮文本,但在IE中,我可以看到左右两侧都产生了额外的填充...

Would there be any CSS rule that can allow me to take away these padding? 是否有任何CSS规则可以让我带走这些填充? Thanks. 谢谢。

Might be a bit late, but when I searched SO for the very same problem today I found this question . 可能会有点晚,但是当我今天搜索SO以寻找同样的问题时,我发现了这个问题 Obviously, this is no real padding (in a sense that it cannot be turned off by padding:0px ), but rather one of those weird oddities that we all love so much about IE. 显然,这不是真正的填充(在某种意义上它不能通过padding:0px来关闭padding:0px ),而是我们都非常喜欢IE的那些奇怪的奇怪之一。 (Note how the false padding scales with button text length O_o). (注意假填充如何与按钮文本长度O_o一起缩放)。 Fortunately, there is a simple solution to it, as described here . 幸运的是,有一个简单的解决方案,它作为描述在这里

Basically you only add overflow:visible; 基本上你只添加overflow:visible; to the button (I did not need the extra width:auto; as described there). 按钮(我不需要额外的width:auto;如此处所述)。 Don't ask - it's absolutely not what you'd have thought this should do, but well... It's IE Land and the rules are different over there. 不要问 - 这绝对不是你认为应该做的,但是......这是IE Land,规则在那里不同。 Just note that this apparently does not work when your buttons are inside a table cell. 请注意,当您的按钮位于表格单元格内时,这显然不起作用。

I guess the CSS reset might have solved this, because someone already included this in some global declaration. 我想CSS重置可能已经解决了这个问题,因为有人已将此包含在一些全局声明中。 Just adding this answer to shed some more light on the how and why. 只需添加此答案,就如何以及为何提供更多信息。

Never give up, people - our children will see a world without IE quirks... One can hope. 永远不要放弃,人们 - 我们的孩子将会看到一个没有IE怪癖的世界......人们可以希望。

Managed to avoid extra spacing in IE with extra statement display:block; 使用额外语句显示来管理以避免额外的间距:块; in CSS like so: 在CSS中如此:

.menu button{
    display:block;
    width:100%;
    padding:0;
}

Note that I didn't use width:auto as it wasn't an option in my case - buttons are empty, width is taken from parent div. 请注意,我没有使用width:auto,因为它不是我的选项 - 按钮为空,宽度取自父div。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM