按钮中的图像:奇怪的空间2.0(这次是IE7)

发布于 2024-09-27 04:01:42 字数 1233 浏览 5 评论 0原文

这是我之前的问题的后续问题。它解决了 Firefox 中的渲染问题。解决该问题后,我显然在其他浏览器中测试了该设计。显然 - 这怎么可能不同 - 我遇到了另一个渲染问题,这次是在 IE7 中。

Internet Explorer 7 中按钮中的图像呈现问题 http://b.imagehost.org/0451/NastySpace2 .png

上述元素中的前一个是一个包含 imgbutton。后者是一个包含 imgdiv

在前一种情况下(带有 buttonimg 的情况),img 的边框和 img 的边框之间有一个空格>按钮。我想摆脱它。

CSS:

* {
    margin: 0;
    padding: 0;
}

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

img {
    display: block;
}

/* this is a fix for one of the padding issues in IE7 */
button {
    overflow: visible;
}
/* this is a fix for the problem in Firefox linked above */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

请帮助我,说实话我开始感到非常生气。这是我使用此 button 标签遇到的第三个 padding 错误...

编辑:我正在针对这个问题给予赏金,以获得一个对 IE7 问题或与

This is a followup to my previous question. It dealt with a rendering issue in Firefox. After that issue was fixed I obviously tested the design in other browsers. And obviously - how could it be different - I encountered yet another rendering issue, this time in IE7.

Image in Button rendering issue in Internet Explorer 7 http://b.imagehost.org/0451/NastySpace2.png

The former of the above elements is a button containing an img. The latter is a div containing an img.

In the former case (the one with button and img) there is a space between the border of the img and the border of the button. I want to get rid of it.

CSS:

* {
    margin: 0;
    padding: 0;
}

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

img {
    display: block;
}

/* this is a fix for one of the padding issues in IE7 */
button {
    overflow: visible;
}
/* this is a fix for the problem in Firefox linked above */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

Please help me, I'm starting to feel really pissed to be honest. This is the third padding bug I encounter with this button tag...

Edit: I am giving bounty on this question, to either get a more at-the-root fix for the IE7 problem or for tipoffs about other browser-bugs related to <button>s. I want to have a button that looks perfectly, pixel for pixel the same in all major browsers. (PS: IE6 is not a major browser.)

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

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

发布评论

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

评论(5

梦醒时光 2024-10-04 04:01:42

好吧,看来我必须得出这样的结论:这个问题没有解决办法——至少没有已知的解决办法。因此,我没有其他选择,只能手动删除这个空间(使用负边距)。

以下是我的完整修复列表,这些修复使 button 元素在 Firefox、Safari、Chrome、Opera、Internet Explorer(IE9、IE8、IE7,尚未测试 IE6)中看起来相同:

button img {
    display: block; /* required to get rid of bottom space in many browsers */
    *margin: -1px -1px -3px -1px; /* remove additional space in IE7 */
}

button {
    overflow: visible; /* remove content-size dependent padding in IE7 */
}
button::-moz-focus-inner {
    border: 0;  /* remove inner focus from Firefox. The inner focus takes up */
    padding: 0; /* padding in Firefox even if not focused due to a bug */
}
button:focus {
    outline: 1px dotted black; /* as we removed the inner focus give it an outer focus ring to improve accessibility */
}

压缩版本:

button img{display:block;*margin:-1px -1px -3px -1px}
button{overflow:visible}
button::-moz-focus-inner{border:0;padding:0}
button:focus{outline:1px dotted black}

删除换行符:

button img{display:block;*margin:-1px -1px -3px -1px}button{overflow:visible}button::-moz-focus-inner{border:0;padding:0}button:focus{outline:1px dotted black}

享受一致的按钮的乐趣!

Well, it seems that I must conclude that there is no fix for this one - at least no known fix. Thus I saw no alternative then manually removing this space (using negative margins).

Here is my complete list of fixes that makes the button element look the same in Firefox, Safari, Chrome, Opera, Internet Explorer (IE9, IE8, IE7, haven't tested IE6):

button img {
    display: block; /* required to get rid of bottom space in many browsers */
    *margin: -1px -1px -3px -1px; /* remove additional space in IE7 */
}

button {
    overflow: visible; /* remove content-size dependent padding in IE7 */
}
button::-moz-focus-inner {
    border: 0;  /* remove inner focus from Firefox. The inner focus takes up */
    padding: 0; /* padding in Firefox even if not focused due to a bug */
}
button:focus {
    outline: 1px dotted black; /* as we removed the inner focus give it an outer focus ring to improve accessibility */
}

Compressed version:

button img{display:block;*margin:-1px -1px -3px -1px}
button{overflow:visible}
button::-moz-focus-inner{border:0;padding:0}
button:focus{outline:1px dotted black}

Removed line breaks:

button img{display:block;*margin:-1px -1px -3px -1px}button{overflow:visible}button::-moz-focus-inner{border:0;padding:0}button:focus{outline:1px dotted black}

Have fun with consistent buttons!

朕就是辣么酷 2024-10-04 04:01:42

那么 display:block 不能解决这个问题吗? img 的 vertical-align:bottom 怎么样?你能在 jsfiddle.net 上设置一个测试用例吗?

编辑:按钮上的 display:block 似乎可以做到这一点:http:// /work.arounds.org/sandbox/48/run

编辑#2:顽固啊..这有效吗? http://work.arounds.org/sandbox/48

So display:block doesn't fix it? How about vertical-align:bottom for the img? Can you setup a testcase on jsfiddle.net?

EDIT: display:block on the button seems to do it: http://work.arounds.org/sandbox/48/run

Edit #2: Stubborn huh.. does this work? http://work.arounds.org/sandbox/48

清音悠歌 2024-10-04 04:01:42

您是否尝试过向按钮添加 width:auto ?

button {    
    overflow: visible;
    width: auto;
}

Have you tried adding width:auto to the button?

button {    
    overflow: visible;
    width: auto;
}
最偏执的依靠 2024-10-04 04:01:42

我经常发现自己咒骂按钮,然后通过使用 onclick Javascript 提交显示图像来解决问题。

哈克?也许。但对于我为一家国际银行做过的 100 多个主要信用卡网站来说,这是一个可以接受的解决方案……而且迄今为止,我还没有找到比这更挑剔的客户。

I often find myself cursing at buttons and then solving the problem by displaying an image with an onclick Javascript submit.

Hackish? Perhaps. But it's an acceptable solution for the 100+ major credit card websites I did for an international bank....and to date, I haven't found a more picky client.

百思不得你姐 2024-10-04 04:01:42

我通过使用 而不是

尝试一下,它会让你省去很多麻烦。

I get around this issue by using an <input type="image" /> instead of a <button /> and using javascript to modify the image shown when the mousedown and mouseup events is triggered.

Try it, it'll save you a big headache.

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