$(document).ready(function() {
$(".glyphicon-play-circle").click(function() {
$(".movie").css("display", "block")
$("#bgvid").toggleClass("is-not-active");
$(".fullscreen").toggleClass("is-video-active");
$(".fullscreen.is-video-active").prop("autoplay", true);
});
});
* {
box-sizing: border-box;
;
}
body,
html {
height: 100%;
}
.logo {
float: left;
width: 50%;
}
.glyphicon {
font-size: 3em;
text-align: center;
}
.header {
position: relative;
z-index: 1;
}
nav {
float: right;
width: 50%;
}
nav ul {
list-style: none;
}
nav li {
float: left;
padding: 15px
}
nav li a {
display: block;
color: #000;
margin-top: 1em;
}
.centered {
position: relative;
top: 50%;
z-index: 1;
color: #fff;
text-shadow: 1px 1px 10px #000;
}
.content {
/*position: relative;*/
}
video {
background-size: cover;
width: 100%;
position: absolute;
height: auto;
top: 0;
left: 0;
z-index: -1;
object-fit: contain;
}
.movie {
display: none;
position: absolute;
z-index: 1;
top: 0;
width: 100%;
height: 100vh;
background: black;
}
.is-not-active { display: none;}
.fullscreen { display: none; }
.fullscreen.is-video-active {
position: fixed;
left: 0;
top: 0;
width: 0;
right: 0;
height: 100%;
width: 100%;
z-index: 9999;
background: #000;
display: block;
}
.is-video-active video {
right: 0;
width: auto;
height: 100%;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<section class="header container">
<div class="logo">
<img src="https://dummyimage.com/150" alt="">
</div>
<nav>
<ul>
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="">Teach</a></li>
<li><a href="">Contact us</a></li>
</ul>
</nav>
</section>
<section class="content">
<div class="container-fluid">
<div class="centered">
<h1 class="text-center">We Evolve with our students</h1>
<a href="#">
<span class="glyphicon glyphicon-play-circle"></span>
<a/>
</div>
</div>
<video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" playsinline autoplay muted loop>
<!-- WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button -->
<source src="http://thenewcode.com/assets/videos/polina.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4">
</video>
<div class="container">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Collapsible Group Item #1
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingTwo">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Collapsible Group Item #2
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingThree">
<h4 class="panel-title">
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
Collapsible Group Item #3
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
<div class="panel-body">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
</div>
</div>
</div>
</div>
</div>
</section>
<section class="fullscreen">
<video poster="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/polina.jpg" id="bgvid" playsinline muted loop>
<!-- WCAG general accessibility recommendation is that media such as background video play through only once. Loop turned on for the purposes of illustration; if removed, the end of the video will fade in the same way created by pressing the "Pause" button -->
<source src="http://thenewcode.com/assets/videos/polina.webm" type="video/webm">
<source src="http://thenewcode.com/assets/videos/polina.mp4" type="video/mp4" style="display: none;">
</video>
</section>
</body>
謝謝!我仍然試圖理解它,我想要一個視頻作爲預告片,當你點擊它時,它會運行其他電影,因爲我支付了兩部電影。它不會起作用嗎? – Nofel
@Nofel你想運行預告片上的全屏div點擊嗎? –
是的,通過電影我的意思是有聲廣告,其中預告片僅僅是幾秒鐘而靜音。 – Nofel