首页 > 解决方案 > 如何在顶部包装上添加视频而不是照片?

问题描述

我想在我的顶部包装位置使用视频,而不是使用照片作为背景 img。我真的是 html5 和 css3 的初学者,所以如果我的问题不清楚,我真的很抱歉。

如果有人能教我如何编写代码以添加背景视频而不是全屏类型的背景,那将非常感激,仅适用于我的顶级包装器。

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>TakashiKaida</title>
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
  </head>
  <body>
    <header>
      <div class="container">
        <div class="header-left">
        </div>
        <div class="header-right">
          <a href="file:///Users/takashikaida/Documents/Takashi%20Kaida%20Personal/index.html">Home</a>
          <a href="#" class="about">About</a>
          <a href="#" class="blog">Blog</a>
          <a href="#" class="cv">CV</a>
        </div>
      </div>
    </header>
    <div class="top-wrapper">
      <div class="container">
        <h1>HELLO, IT'S ME.</h1>
        <h1>I AM TAKASHI</h1>
        <p><br><br>Marketing Analyst/Assistant</p>
        <p>Co-Founder and CEO of <a href="file:///Users/takashikaida/Desktop/Flow%20Full%20Screen%20Type/index.html" target="_blank"> <strong>FLOW</strong></a></p>
        </div>
      </div>
    </div>

CSS:

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN";
}

a {
  text-decoration: none;
}

.container {
  width: 1170px;
  padding: 0 15px;
  margin: 0 auto;
}

.top-wrapper {
  padding: 180px 0 100px 0;
  background-image: url(background-photo.jpg);
  background-size: cover;
  color: white;
  text-align: center;
  opacity: 0.8;
}

.top-wrapper h1 {
  font-size: 75px;
  letter-spacing: 5px;
  padding-top: 5px;
}

.top-wrapper p {
  font-size: 25px;
}

header {
  height: 65px;
  width: 100%;
  background-color: rgba(34, 49, 52, 0.9);
  position: fixed;
  top: 0;
  z-index: 10;
}


.logo {
  width: 124px;
  margin-top: 20px;
}

.header-left {
  float: left;
}

.header-right {
  float: right;
  transition: all 0.5s;
}


.header-right a {
  line-height: 65px;
  padding: 0 25px;
  color: white;
  display: block;
  float: right;
}

.about-me {
  height: 500px;
  padding-bottom: 80px;
  background-color: #f7f7f7;
  text-align: center;
}

.heading {
  padding-top: 60px;
  padding-bottom: 30px;
  color: #5f5d60;
}

.heading h1 {
  font-weight: normal;
}

.profile {
  float: left;
  width: 25%;
}

.lesson-icon {
  position: relative;
}

.lesson-icon p {
  position: absolute;
  top: 90px;
  width: 100%;
  color: white;
}

.txt-contents {
  width: 80%;
  display: inline-block;
  margin-top: 20px;
  font-size: 12px;
  color: #b3aeb5;
}

.heading h3 {
  font-weight: normal;
}

.message-wrapper {
  border-bottom: 1px solid #eee;
  padding-bottom: 80px;
  text-align: center;
}

.message {
  padding: 15px 40px;
  background-color: #5dca88;
  cursor: pointer;
  box-shadow: 0 7px #1a7940;
}

.message:active {
  position: relative;
  top: 7px;
  box-shadow: none;
}

.bottom-btn-list {
  text-align: center;
}


footer p {
  color: #b3aeb5;
  font-size: 12px;
  margin: auto;
  width: 50%;
  padding: 30px;
  text-align: center;
}


footer {
  padding-top: 30px;
  text-align: center;
  background-color: #333631
}

.my-skyblue {
  color: skyblue;
}

.my-white {
  color: white;
}

标签: javascriptcsshtml

解决方案


这是一个想法,你可以试试:

  1. 您可以使用video标签导入您的视频文件
  2. 设置样式video,例如:
video {
 min-width: 100%; min-height: 100%;
 width: auto; height: auto; z-index: -100;
}

推荐阅读