Video lightboxes are a great way to add some extra style and pizzazz to your Squarespace website. They allow you to showcase a video in a larger format, with a lightbox overlay.
In this article, we’ll show you how to create a video lightbox in Squarespace.
First, you’ll need to add your video to your Squarespace site. To do this, go to the Content tab and click on the Videos section. Then, click on the Add Video button.
Once you’ve added your video, click on the Settings icon (the cog icon) and select the Embed tab. In the Video Code field, paste in the embed code for your video. If you’re unsure how to get the embed code for your video, check out this help article.
Once you’ve added your embed code, click on the Save button and then click on the Close button.
Now that your video has been added to your Squarespace site, it’s time to create the lightbox. To do this, go to the Design tab and click on the Custom CSS section. Then, paste in the following CSS code:
.video-lightbox {
position: relative;
cursor: pointer;
}video-lightbox img {
display: block;
}video-lightbox .play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px; /* Make play button size adaptable */ /* Play button could be an image (SVG recommended) */ /* Or could be generated by pseudo elements */ /* Or could just be a colored circle with 'play' text inside */ /* Your choice */ }
.play-button:before { /* This is only needed if using pseudo elements for play button */ content:""; }
/* The lightbox overlay element */ .lightbox { position: fixed; top: 0; left: 0; bottom: 0; right: 0; background-color:#000; opacity:0; transition: all 0.5s ease-in-out;}
.lightbox .close { position: absolute; top:-80px; right:-80px;}
.content { position: absolute; top:-9999px;}
/* When clicked on, start playing video + show lightbox overlay */ .video-lightbox img { opacity : 1;}/* Fade image out while keeping div container visible*//* Set image opacity back when hovering over div container*//* This is necessary because otherwise clicking anywhere on page will close lightbox (due to body's default :hover behavior)*/
.play-button { opacity : 1;}/* Fade play button in while keeping div container visible*//* Set play button opacity back when hovering over div container*/
Creating a video lightbox in Squarespace is easy, but there are a few things to keep in mind. First, you need to have a Squarespace account and be logged in. Second, you need to be using the latest version of the Squarespace interface. And third, you need to have a video uploaded to your account.
Once you have all of those things, you can follow the instructions in the article to create your own video lightbox. Just remember to save your changes before you publish your site!
.close i{ font – size : 80px ;}/* Set close icon size*/
.video - lightbox : hover img , /* These styles are applied when hovering over parent div */ /* The close button will only be visible when hovering over parent div */ /* The play button will be hidden when hovering over parent div since we don't want 2 play buttons */ /* Note that these styles are not necessary if not using an image for the parent div (as in our example) */ /* In that case , you can just remove these styles or make them more specific so they only apply when needed */ .video - lightbox : hover .close i , .play - button { opacity : 0 ; }
.video - lightbox img , /* These styles are applied when not hovering over parent div or when lightbox is closed*/ /* Note that these styles are not necessary if not using an image for the parent div (as in our example)*/ .video - lightbox .video - lightBox : Target img , #VideoModal : Target img{ opacity : 1 ; }
.Video - LightBox , #VideoModal{ z - index : 99999 ;/* Make sure LightBox is on top of everything else on page*//* You can change 99999 to any number you want depending on what's on your page*//* If you have other modals or LightBoxes , make sure they have a lower z - index than this one so they are underneath*/ }
.VideoModal{ width : 100% !important ; height : 100% !important ; padding : 0 !important ; }
$(document).ready(function(){ $(“#myBtn”).click(function(){ $(“#myModal”).css(“display”,”block”); }); $(“#myBtn”).click(function(){ $(‘#iframe’).attr(‘src’, $(‘#iframe’).attr(‘src’)+ ‘&autoplay=1’); }); $(“.close”).css(“display”,”none”); }); }); // Get YouTube or Vimeo URL from data attribute var url = $(‘#iframe’).data(‘src’); // Assign autoplay=1 parameter to URL var autoplayUrl = url+’&autoplay=1′; // Set dynamically created iframe src attribute to autoplay URL $(‘#iframe’).attr(‘src’, autoplayUrl); // Remove dynamically created iframe element once playing $(‘#iframe’).remove(); }); }); // Get YouTube or Vimeo URL from data attribute var url = $(‘#iframe’).remove(); });