【问题标题】:Content is showing up inside jumbotron movie内容出现在 jumbotron 电影中
【发布时间】:2018-01-22 13:10:12
【问题描述】:

我正在按照这个答案的建议使用引导程序在我的 jumbotron 中显示背景电影:
https://stackoverflow.com/a/34624728/9072894

问题是网站的内容显示在 inside jumbotron/电影中。这是一个显示问题的小提琴:
https://jsfiddle.net/cortical_iv/kae4q601/228/

例如,<p> 下面的内容出现在 inside jumbotron:

<div class="jumbotron">
  <video id="video-background" preload muted autoplay loop>
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  </video>
  <div class="container">
    Hello World. I am in the jumbotron. As I should be.
  </div>
</div>

<p>
Here is my content. It inside the jumbotron. I want it to be outside the jumbotron.
</p>

我怎样才能让jumbotron/电影有清晰的界限?例如,我网站的主要内容,比如这个简单示例中&lt;p&gt; 中的内容,出现在jumbotron 之外? 'Hello World' 意味着在 jumbotron 内。

【问题讨论】:

  • 这是因为 video 有一个fixed position。你有什么要求?
  • 你想让“Hello World”和

    标签离开jumbotron吗?

  • 我已经在问题中澄清了我所追求的:“hello world”应该在 jumbotron 中。以&lt;p&gt;开头的内容是网站的主要内容,应该在jumbotron之外。我还更新了小提琴以使其更加清晰。
  • 检查这个小提琴? Do you want something like this
  • 是的,@DragonBorn 这正是我所追求的。虽然我没有足够的代表来投票,但似乎你应该把它变成一个答案。

标签: css twitter-bootstrap


【解决方案1】:

它没有工作,因为它有一个fixed 位置。

根据您的要求。您甚至不需要引导程序 jumbotron 并且可以使用纯 css 实现相同的功能,并且可以使用 absolute 定位将您的元素放置在 video 元素内。检查sn-p

#video-background { 
  overflow: hidden;
  z-index: -100;
  width:100%;
  height: 100%;
}

.div--wrapper {
  position: absolute;
  top: 50px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div>
  <video id="video-background" preload muted autoplay loop>
    <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4">
  </video>
  <div class="div--wrapper">
    Hello World. I am in the jumbotron. As I should be.
  </div>
</div>

<p>
Here is my content. It outside the jumbotron as it is intended to be.
</p>

【讨论】:

  • 我是否可以建议将 container 类重命名为其他名称,这样它就不会与非常常用于描绘网格结构的内置引导类发生冲突?我把它改名为container_vid,可能不是最好的名字。 :)
  • 我已根据 BEM 命名约定更改了 class container。有关如何命名您的 HTMLCSS 的更多信息Check This
  • 谢谢。仍然无法投票。 :( 我注意到一件事:当你缩小窗口时,电影中的文本实际上并没有与内容正文中的文本保持分离。例如,“hello world”句子,变得与“这是我的内容,它在 jumbotron 语句之外”。因此,在“jumbotron”和网站正文之间并没有真正保持严格的内容分离。
  • 针对我之前的担忧,我认为明智的做法是将文本设置为不换行......事实上,此时我只是将宽度/高度固定在某个像素值而不是让它调整大小,因为让它调整大小会带来各种各样的痛苦。因此,我将您的代码中的 100% 改为 X 和 Ypx,而不是 100%。
  • 也许你应该看看positioning。由于div--wrapper 具有绝对位置,因此它将忽略所有其他position properties。阅读它,你就会明白为什么会这样。
猜你喜欢
  • 2017-07-20
  • 1970-01-01
  • 1970-01-01
  • 2012-02-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多