按钮中的图像:奇怪的空间2.0(这次是IE7)
这是我之前的问题的后续问题。它解决了 Firefox 中的渲染问题。解决该问题后,我显然在其他浏览器中测试了该设计。显然 - 这怎么可能不同 - 我遇到了另一个渲染问题,这次是在 IE7 中。
Internet Explorer 7 中按钮中的图像呈现问题 http://b.imagehost.org/0451/NastySpace2 .png
上述元素中的前一个是一个包含 img
的 button
。后者是一个包含 img
的 div
。
在前一种情况下(带有 button
和 img
的情况),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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
好吧,看来我必须得出这样的结论:这个问题没有解决办法——至少没有已知的解决办法。因此,我没有其他选择,只能手动删除这个空间(使用负边距)。
以下是我的完整修复列表,这些修复使
button
元素在 Firefox、Safari、Chrome、Opera、Internet Explorer(IE9、IE8、IE7,尚未测试 IE6)中看起来相同:压缩版本:
删除换行符:
享受一致的
按钮
的乐趣!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):Compressed version:
Removed line breaks:
Have fun with consistent
button
s!那么
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 aboutvertical-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/runEdit #2: Stubborn huh.. does this work? http://work.arounds.org/sandbox/48
您是否尝试过向按钮添加 width:auto ?
Have you tried adding width:auto to the button?
我经常发现自己咒骂按钮,然后通过使用 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.
我通过使用
而不是
尝试一下,它会让你省去很多麻烦。
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.