Scroll-triggered Fixed Video Player With jQuery And CSS3

File Size: 2.01 KB
Views Total: 7755
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Scroll-triggered Fixed Video Player With jQuery And CSS3

A small jQuery script that automatically fixes the video player box at the bottom of the webpage as you scroll a certain distance from the top (the video player is scrolled out of the viewport). Just like the fixed video box as you seen in the

How to use it:

1. Embed an HTML5 video into the video box.

<div id="videoBox" class="box">
  <video width="400" controls>
    <source src="sample.mp4" type="video/mp4"> 
    Your browser does not support HTML5 video.

2. Fix the video box when it's scrolled out of view.

#videoBox.out {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 300px;
  z-index: 999;
  animation: an 0.5s;
} { animation: ac 1s; }

3. Place the necessary jQuery library in the document.

<script src="//"></script> 

4. The jQuery script to detect the scroll event and toggle the CSS classes as you scroll down the webpage.

var ha = ( $('#videoBox').offset().top + $('#videoBox').height() );


  if ( $(window).scrollTop() > ha + 500 ) { 
  } else if ( $(window).scrollTop() < ha + 200) {  
  } else {       


This awesome jQuery plugin is developed by jlnljn. For more Advanced Usages, please check the demo page or visit the official website.