iframe 在某些浏览器尺寸上向左移动 1 像素
我有类似的代码,抱歉我现在没有确切的代码。 但它是有效的。
<iframe src="..." borderframe="0" scrolling="no" width=728px" height="90px"></iframe>
目标是一个 html 文件,其中包含横幅代码。 一切都显示良好。 但是当我调整浏览器大小或最大化时。 内容向左移动 1 个像素。 因此横幅显示缺少第一条 1 像素垂直线。 并且只有 727px 可见。
有人有主意吗?
谢谢。
i have code like, sorry i dont have the exact code now. but its valid.
<iframe src="..." borderframe="0" scrolling="no" width=728px" height="90px"></iframe>
the target is a html file that contains code for a banner.
everything displays well. but when i resize browser or go to maximize. the content is shiftet to the left by 1 pixel. so the banner is displayed missing the first vertical 1px line. and only 727px is visible.
anyone has an idea?
thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我有一个想法,但你没有给我们完整的图片,所以我可能还很遥远。
我猜测 iframe 的位置是通过百分比或某种除法计算来定位的,例如父级左侧的 40%。 然后,在某些浏览器宽度下,该数字不会均匀划分并被截断。 假设它距离左侧 100 像素,您将父级缩小 2/3,使其定位变为 66.66 像素,浏览器将其截断为 66,从而留下一个像素的明显误差。
I have an idea, but you haven't given us the whole picture, so I might be way off.
I would guess that the iframe is positioned with a percentage or some sort of division calculation like 40% left of parent. Then at certain browser widths this number doesn divide evenly and gets truncated. Say it is at 100px in from the left side, and you shrink the parent by 2/3rds so that its positioning would become 66.66 pixels, and the browser cuts this off to 66, giving an apparent error of one pixel left.
代码被“简单”地放在 div 容器中。
没有百分比或相对宽度。 :(
the code is put "plain" in a div container.
there is no percentage or relative width. :(
我也有同样的问题。 看起来像是一种“舍入误差”,尽管这些应该从 1.5 开始就在 FF 中得到修复? 我认为关键在于 IFRAME 位于页面中心的 DIV 内。 当窗口大小小于 DIV 的大小时,一切都很好。 当窗口大小增加并且大小达到偶数(或奇数)宽度时,边框就会消失。
I'm having the same issue. What it seems like is a kind of "rounding error" even though these were supposed to have been fixed in FF since 1.5? The key thing about this I think is that the IFRAME is within a DIV that is centered on the page. When the window size is less than that of the DIV, everything's fine. When the window size increases and the size is brought up to an even (or maybe odd) width, is when the border disappears.
解决方案:
您可以将
0.5px
添加到width
solution:
u can add
0.5px
towidth