2017-01-23 4 views
2

Ich bin relativ neu zu jQuery, aber wirklich mag, was es tun kann, mache ich gute Fortschritte, aber ich bin nicht in der Lage zu erreichen, ein div zu öffnen, wenn ich Play drücken. Ich möchte Bootstrap Modal für dieses Projekt nicht verwenden. Ich möchte das Video als volle Breite und Höhe der Darstellungsfeldbreite und -höhe öffnen. Derzeit wird nicht abgespielt, hier ist meine codepen und mein Code ist unten.Erstellen eines Vollbild-Video-Overlay ohne Bootstrap

Als Beispiel möchte ich etwas wie this erreichen, wenn das Spiel gedrückt wird.

$(document).ready(function(){ 
    $(".glyphicon-play-circle").click(function(){ 
     $(".movie").css("display","block") 
    }) 
}) 

CSS

.movie{ 
    display:none; 
    position:absolute; 
    z-index:1; 
    top:0; 
    width:100%; 
    height:100vh; 
    background:black; 

}

Antwort

1

ich eine Änderung am Code vorgenommen habe. Ich habe den Vollbild-Inhalt deaktiviert, weil ein Video ausreicht, um es voll zu machen. Keine Notwendigkeit zusätzliches Video, damit es funktioniert.

$(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>

+0

Dank! Ich versuche immer noch, es zu verstehen, ich möchte ein Video als Trailer und wenn du darauf klickst, läuft der andere Film, da ich für zwei Filme bezahlt habe. Würde es nicht funktionieren? – Nofel

+0

@Nofel möchten Sie den Vollbild-Div auf dem Trailer Click ausführen? –

+0

ja, mit dem film meine ich die werbung mit ton, wo als trailer nur wenige sekunden und stumm geschaltet sind. – Nofel

Verwandte Themen