【问题标题】:Header with video background, position not working in safari带有视频背景的标题,位置在 Safari 中不起作用
【发布时间】:2015-01-05 05:31:27
【问题描述】:

我正在尝试制作带有视频背景的标题。我在 html 中插入了一个视频,并在 css 中使视频的 z-index -100。

目前它在谷歌浏览器中运行良好,但如果我在 safari 中打开我的网站,视频背景的位置完全错误。

我无法解决这个问题,所以两个浏览器都会显示相同的内容。

可以在这里看到网站:http://www.chatroom.guru

这是我的html: <header> <video autoplay loop poster="polina.jpg" id="bgvid"> <source src="/img/headerbgvideo.mp4" type="video/mp4" id="bgvid"> </video> <div class="container"> <p id="title1">Connect with the world today!</p> <p id="title2">Join the world's best social chatroom for gamers.</p>

这是我的 CSS:

video#bgvid {
position: absolute;
margin-top: -90px;
width: 100%;
z-index: -100;}

希望有人可以帮助我! 谢谢

【问题讨论】:

  • 您是否有任何特殊原因需要绝对定位您的视频?我认为您可以离开视频并绝对定位您的.container。 (但要小心定位正确的.container
  • 感谢您的评论。我仍然无法让它工作......

标签: html css video background header


【解决方案1】:

如何将object-fit:cover 添加到您的视频风格中:

video#bgvid {
    object-fit:cover;
}

【讨论】:

  • 嗯。好的,我认为最好基本上重新开始。您在这里进行了很多样式设置。此外,您的 HTML 一开始就无效。例如,您的 nav uls 嵌套不正确。做你想做的事应该不难,但用你当前的代码可能是不可能的。再试一次,保持简单有效。然后设置绝对最小值。
猜你喜欢
  • 2016-08-06
  • 1970-01-01
  • 2022-07-03
  • 1970-01-01
  • 2011-03-12
  • 2015-12-28
  • 2013-02-12
  • 1970-01-01
  • 2022-06-30
相关资源
最近更新 更多