视频背景转换为彩色背景

时间:2017-03-30 04:17:15

标签: javascript html5 css3

我在视频完成后使用视频作为背景我想将视频背景更改为颜色背景,如红绿色或任何颜色。我正在尝试HTML5但卡住了。任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

试试这段代码,根据我的理解,这可能就是你要搜索的内容,在完成后台视频后,我将身体背景颜色改为红色。

  $(document).ready(function(){
    $('video').on('ended',function(){
    $("video").first().attr('src','')
         $('html, body').css('background','red');
    });
  });
#header {
  border-bottom: 0px;
  margin-bottom: 0px;
}
.featured-area {
  margin-top: 0px;
  margin-bottom: 0px;
}
#recent-posts {
  margin-top: 27px;
}
#blurb {
  margin-bottom: 27px;
  width: 75%;
}
.recent-post-box {
  background-color: #f2f2f2;
  padding-top: 4px;
  margin-top: 40px;
}
#logo {
  display: none;
}
#hero {
  position: relative;
  z-index: 1;
  height: 600px;
  width: 100%;
  margin-bottom: 40px;
  vertical-align: middle;
  text-align: center;
}
#hero #bg {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: url("http://www.makemeapro.org/wp-content/uploads/2015/07/hero-cover-modified.jpg");
  opacity: .4;
  max-width:100%;
  height:auto;
  background-size:cover;
    overflow:hidden;
}
#outerDiv {
  width: 100%;
  height: 100%;
}
.btn {
  background: #3498db;
  background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  background-image: -o-linear-gradient(top, #3498db, #2980b9);
  background-image: linear-gradient(to bottom, #3498db, #2980b9);
  -webkit-border-radius: 28;
  -moz-border-radius: 28;
  border-radius: 28px;
  color: #ffffff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
  border: 0px;
  outline: none;
}

.btn:hover {
  background: #3cb0fd;
  background-image: -webkit-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -moz-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -ms-linear-gradient(top, #3cb0fd, #3498db);
  background-image: -o-linear-gradient(top, #3cb0fd, #3498db);
  background-image: linear-gradient(to bottom, #3cb0fd, #3498db);
  text-decoration: none;
  cursor: pointer;
}

#hero video {
    width:100%;
    height:100%;
    object-fit:cover;
}
<!DOCTYPE html> 
<html> 
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body> 
<div id="hero">
<div id="bg">
     <video autoplay>
        <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"/>
        <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg"/>
      </video>
    
</div>
<table id="outerDiv" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td valign="middle" id="innerDiv">
<div class="post-header"><h1 style="color: #383838;">Helping young professionals navigate the world of work.</h1></div>
<div align="center"><button class="btn">JOIN THE REVOLUTION</button></div>
        </td>
    </tr>
</table>
</div>

</body> 
</html>