margin-bottom 有点跨浏览器的灰色区域
当我使用 margin-bottom 是 CSS 时,结果因浏览器(尤其是可爱的 IE)而异,什么会影响 CSS 属性“Margin”,在我可以在所有浏览器中看到一致的结果之前,我需要检查我已经实现的其他规则。 ..
When i use margin-bottom is CSS, the results vary across browsers (esp lovely IE) what impacts the CSS property "Margin" what other rules do i need to check i've implemented before i can see a consistent result across all browsers...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
某些浏览器 (IE) 会折叠边距。它不仅影响底部边距,还影响顶部边距。
如果您有两个堆叠元素,其边距均为
margin: 10px 0 15px;
,您可能会认为两者之间有 25px 的空间。但是,IE 会折叠边距,因此剩下的就是最大边距(在上面的示例中为 15px)。为了帮助确保浏览器一致地显示内容,一个好的起点是一个好的重置样式表(例如 Eric Meyer 或 YUI)。
Some browsers (IE) collapse margins. It doesn't just affect the bottom margin, but also the top.
If you have two stacked elements, both with a margin of
margin: 10px 0 15px;
, you might think there would be 25px of space between the two. However, IE collapses the margins so all that's left is the greatest margin (which is 15px in the example above).As to helping ensure browsers display things consistently, a good place to start is a good reset stylesheet (Eric Meyer's or YUI's for example).
我会查找诸如“即盒模型错误”之类的内容来了解一些怪癖。大多数时候,如果您看到不同的边距,可能是因为该元素还具有一些解释不同的填充。
但如果您能提供更多详细信息,我们可以详细说明!
I would look up things like 'ie box model bugs' to understand some of the quirks. Most times, if you're seeing different margins, it may because the element also has some padding that's being interpreted differently.
But if you can provide more detail, we can elaborate more!