html - CSS 背景图像/电影 URL?

标签 html css movie

我注意到 GIF 并不是真正兼容所有浏览器,所以我一直在使用电影。直到现在一直在寻找。我有一个带有用 css 编写的背景图片的网站。我觉得这行不通,但我尝试像链接图像一样链接电影,但它甚至没有出现。下面是 html 和 css。

html

 <section id="slider">
  <div class="container">
    <div class="row">
      <div class="col-md-10 col-md-offset-2">
        <div class="block">
          <h1 class="animated fadeInUp">Need a Network?</h1>
          <p class="animated fadeInUp">Then you are in the right place. We can help Design, Setup, Configure, and Maintain a network that fits your exact needs.</p>
        </div>
      </div>
    </div>
  </div>
</section>

CSS

#slider {
background: url("../img/") no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: 10% 0%;
padding: 200px 0 280px 0;
position: relative;
}
#slider:before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(to left, #8b86a3, #322e40);
opacity: 0.8;
}
#slider .block {
color: #E3E3E4;
}
#slider .block h1 {
font-family: 'Roboto', sans-serif;
font-weight: 100;
font-size: 45px;
line-height: 60px;
letter-spacing: 10px;
padding-bottom: 45px;
}
#slider .block p {
font-size: 23px;
line-height: 40px;
font-family: 'Roboto', sans-serif;
font-weight: 300;
letter-spacing: 3px; 
}

据我所知,链接视频是不可能发生的,那么另一种选择是什么?我该怎么做?我需要现在仍然显示的文本,并且电影是不透明的。如果我需要使实际电影本身不透明,我可以这样做。谢谢

可以一起看网站here

最佳答案

您可以使用以下代码在“需要网络”部分后面添加视频:

I replaced the video, and used the JavaScript code to "autoplay" the video!

If you think the video can autoplay without JavaScript, remove it!


I also replaced the iframe tag, with the video tag.

You can replace the video, by changing the src="" attribute on the <source> tag, inside the <video> tag.

function playVideo() {
document.getElementsByClassName('video')[0].play();
}
.video {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
z-index: -2;
object-fit: fill;
}
#slider {
/* Removed the background tags, since there are no image placed in the url of the background tag */
/*background: url("../img/") no-repeat;
background-size: cover;
background-attachment: fixed;
background-position: 10% 0%;*/
padding: 200px 0 280px 0;
position: relative;
}
#slider:before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
background: linear-gradient(to left, #8b86a3, #322e40);
opacity: 0.8;
z-index: -1;
}
#slider .block {
color: #E3E3E4;
}
#slider .block h1 {
font-family: 'Roboto', sans-serif;
font-weight: 100;
font-size: 45px;
line-height: 60px;
letter-spacing: 10px;
padding-bottom: 45px;
}
#slider .block p {
font-size: 23px;
line-height: 40px;
font-family: 'Roboto', sans-serif;
font-weight: 300;
letter-spacing: 3px; 
}
<body onload="playVideo()">
<section id="slider">
  <video class="video" autoplay="autoplay">
    <source src="http://media.w3.org/2010/05/sintel/trailer.mp4" type="video/mp4">
  </video>
  <div class="container">
    <div class="row">
      <div class="col-md-10 col-md-offset-2">
        <div class="block">
          <h1 class="animated fadeInUp">Need a Network?</h1>
          <p class="animated fadeInUp">Then you are in the right place. We can help Design, Setup, Configure, and Maintain a network that fits your exact needs.</p>
        </div>
      </div>
    </div>
  </div>
</section>
</body>

关于html - CSS 背景图像/电影 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44125015/

相关文章:

android - 使用动画 gif 和电影时 Activity 崩溃 (Android)

javascript - 如何在提交后重置表单

html - 将正则表达式运行到新文件(或另一个现有文件)

javascript - 如何让jquery显示和隐藏图像

javascript - 使用 JFiddle 创建网页

html - 居中菜单栏 CSS/HTML

javascript - 通过 html 按钮将对象传递给 javascript 中的函数

javascript - 如何加载 leanmodal div 内容 onclick

iphone - 跳过 UIImagePickerController 预览 View ?