【问题标题】:Margin is rendering differently in m'soft edge Vs. Chrome/ Safari边距在 m'soft edge Vs 中呈现不同。铬/ Safari
【发布时间】:2016-05-31 00:01:21
【问题描述】:

我有一个布局(下面的代码),它在 Chrome 和 Safari 中按预期呈现,但不幸的是,Microsoft Edge 和 Internet Explorer 在元素和我的导航栏之间呈现一个黑条。我能做些什么来阻止这种情况发生?

看这里-

铬:

边缘:

<div class="navbar navbar-inverse" role="navigation" id="slide-nav">
  <div class="container" id="logoStripe">
     <!-- Links -->
  </div>
</div>
<div id="page-content">
  <div class="container-fluid adjustedHeight Page1B">
    <div class="video-container">
      <video autoplay loop id="video">
        <source src="Images/Medium.mp4" type="video/mp4" />
        Your browser does not support the video tag. I suggest you upgrade your browser.</video>
    </div>
  </div>

CSS:

.nav-bar{
    height:77px;
}
.adjustedHeight {
    height: calc(100vh - 77px);
    width: 100%;
    margin-top: -100px;
    padding: 0;
}
video {
    height: 100%;
    width: 100%;
    object-fit : cover;
}
.video-container {
    overflow: hidden;
    display: block !important;
    position: relative;
}
.video-container video {
    position: absolute;
    z-index: 0;
    bottom: 0;
}

【问题讨论】:

  • 请创建一个可以重现问题的工作演示。
  • @LGSon 我无法真正显示问题,因为您需要使用 IE 或 edge,但是,here 是创建探针的完整代码的 JSFiddle。
  • 我正在浏览我的一些较旧的答案,并找到了以下内容。我更新的答案没有帮助你吗?

标签: html css google-chrome internet-explorer microsoft-edge


【解决方案1】:

这里的一个问题是Page1 规则具有margin-top: 30%;

当您对margin-top 使用百分比时,它使用父级宽度来计算边距值,因此只需调整浏览器窗口的大小,这个不需要的间隙就会增加/减少。

更新

我制作了 2 个示例,一个 update of you fiddle 和一个非常简单的示例 sn-p,显示了另一种选择。

关于小提琴,请检查问题是否消失。我所做的只是从其元素中删除Page1 类并删除&lt;div id="page-content"&gt; 元素。

示例 sn-p

html, body {
  height: 100%;
  margin: 0;
}
.container {
  height: 100%;
  padding-top: 80px;
  box-sizing: border-box;
}
.navbar {
  position: fixed;
  height: 80px;
  top: 0;
  left: 0;
  width: 100%;
  background: #bbb;
}
.content {
  height: 100%;
}
video {
  display: block;
	height: 100%;
	width: 100%;
	object-fit : contain;
}
<div class="container">
  <div class="navbar">

  </div>
  <div class="content">

    <video autoplay loop mob-hide id="video">
      <source src="http://www.html5videoplayer.net/videos/toystory.mp4" type="video/mp4" />
      Your browser does not support the video tag.
      I suggest you upgrade your browser.
    </video>

  </div>
</div>

【讨论】:

  • 谢谢。恐怕改成top: 30%; 也改不了问题。
  • @GeorgeEdwards 解释您希望它的外观,我可能会建议一些其他方法来实现您想要的。您能否确认,当您移除 margin-top 时,IE 和 Chrome 呈现相同的内容?
  • 我想要一个全宽全高视频,触摸导航栏底部和屏幕底部(不再进一步)保持纵横比,隐藏溢出。
  • 如果我删除 page1 css,那么它仍然会在边缘呈现黑条,但在 chrome 中没有黑条。唯一的区别是按钮弹到顶部。
  • @GeorgeEdwards 好的,我稍后会回来,给你画个样本。
猜你喜欢
  • 2018-05-06
  • 2017-10-16
  • 2017-09-16
  • 2016-10-07
  • 1970-01-01
  • 2012-12-28
  • 2018-07-13
  • 2019-06-01
  • 1970-01-01
相关资源
最近更新 更多