How to setup Video Player to be floating?

How do I setup the videoplayer to be free floating, so that when user scrolls down a page, the video player follows the user along the page?

Thank you for your help!

Welcome to Gumlet, @usegumlet .

To create a free-floating video player that follows the user as they scroll down a page, you can use a combination of HTML, CSS, and JavaScript. Here’s a basic example to get you started:


First, you need to include your video player in your HTML. For simplicity, let’s use the HTML5 <video> element:

<video id="floatingVideo" controls>
  <source src="your-video-file.mp4" type="video/mp4">
  Your browser does not support the video tag.


Then, use CSS to style your video player so that it becomes a floating element:

#floatingVideo {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 300px;
  height: auto;
  z-index: 1000;

This CSS will make your video player appear in the bottom right corner of the page. It will also ensure that the video player stays on top of other page content.


To make the video player dynamically adjust its visibility based on the user’s scroll position, you can use JavaScript:

window.addEventListener('scroll', function() {
  var video = document.getElementById('floatingVideo');
  var scrollPosition = window.scrollY || document.documentElement.scrollTop;

  // Set a threshold for when the video should start floating
  var threshold = 200; // in pixels

  if (scrollPosition > threshold) { = 'block';
  } else { = 'none';

This JavaScript listens for the scroll event and checks the user’s scroll position. If the user has scrolled more than a certain threshold (200 pixels in this case), the video player will be shown; otherwise, it will be hidden.

Putting It All Together

You would include the HTML in your webpage where you want the video to be originally placed. The CSS can go into your stylesheet, and the JavaScript can be included in a script tag or an external JavaScript file.

Remember, this is a basic implementation. Depending on your specific requirements and the context of your webpage, you might need to adjust the code. Also, consider the user experience, as floating elements can sometimes be intrusive or distracting.

1 Like

You are a superstar :slight_smile:

1 Like