按钮中的图像:奇怪的空间

发布于 2024-09-27 05:51:10 字数 532 浏览 1 评论 0原文

首先是 Firefox 4 Beta 8 中的结果:

Button 与 Div http://b.imagehost.org/ 0419/buttonSpace.png

前面显示的元素是带有 imgbutton,后者是带有 div img.正如您在前一种情况中看到的那样,img 的边框和 button 的边框之间存在一些奇怪的空间。我想知道如何删除它。

这里是 CSS 文件:

* {
    margin: 0;
    padding: 0;
}

button, img, div {
    border: 1px solid black;
}

img {
    display: block;
}

First the result in Firefox 4 Beta 8:

Button vs Div http://b.imagehost.org/0419/buttonSpace.png

The former element shown is a button with an img the latter is a div with an img. As you can see in the former case there is some strange space between the border of the img and the border of the button. I wonder how I can remove it.

Here the CSS file:

* {
    margin: 0;
    padding: 0;
}

button, img, div {
    border: 1px solid black;
}

img {
    display: block;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦中楼上月下 2024-10-04 05:51:10

在其他浏览器中测试上述测试用例表明,这可能不是 CSS 问题,而是 Firefox 中的错误。经过一番研究后,我发现了这个错误报告: Bug 140563 -

在该错误报告中,有一个针对该问题的修复:

button::-moz-focus-inner {padding:0; border:0}

Testing the above testcase in other browsers has shown that this probably isn't a CSS issue but a bug in Firefox. After a little bit of research I found this bug report: Bug 140563 - <button> ignores CSS style padding:0

In that bug report there is a fix for the problem:

button::-moz-focus-inner {padding:0; border:0}
再浓的妆也掩不了殇 2024-10-04 05:51:10

我认为你必须为 div 设置一个 width

I think you have to set a width for the div

青萝楚歌 2024-10-04 05:51:10

您要求的 padding 似乎没有被应用。您是否尝试过在按钮上明确设置它?

It looks like the padding you're asking for is not being applied. Have you tried setting it explicitly on the button?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文