CSS Only Video Lightbox

Size
3,250 Kb
Views
36,432

How do I make an css only video lightbox?

Would probably use JS to stop playback on close, but not really inline with my goal for this exercise.. What is a css only video lightbox? How do you make a css only video lightbox? This script and codes were developed by Drew McConville on 31 August 2022, Wednesday.

CSS Only Video Lightbox Previews

CSS Only Video Lightbox - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS Only Video Lightbox</title> <script src="https://use.typekit.net/uqf0mlo.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="flex"> <label class="btn" for="show-vid">Show Video</label>
</div>
<input id="show-vid" type="checkbox" />
<div id="overlay" for="show-vid"> <div class="video-wrapper"> <label class="close" for="show-vid">Hide Video</label> <iframe width="560" height="315" src="https://www.youtube.com/embed/ScMzIvxBSi4" frameborder="0" allowfullscreen></iframe> </div>
</div>
</body>
</html>

CSS Only Video Lightbox - Script Codes CSS Codes

@charset "UTF-8";
input[type="checkbox"] { display: none;
}
.flex { display: flex; align-items: center; height: 100vh;
}
.close { width: 2rem; height: 2rem; background-color: rgba(255, 255, 255, 0.85); border-radius: 100%; display: block; font-size: 1px; text-indent: -999em; position: absolute; border: 1px solid #000; top: -1rem; right: -1rem; z-index: 999; box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.35); transition: all 0.25s ease-out;
}
.close:hover, .close:focus { transform: scale(1.1); background-color: white;
}
.close:after { font-weight: 300; content: "×"; text-indent: 0; font-size: 1.4rem; position: absolute; top: 0.15rem; left: 0.525rem;
}
.btn { font-family: "tondo", sans-serif; cursor: pointer; border: 1px solid #aaa; margin: 0 auto 3em; display: block; width: 200px; text-align: center; padding: 0.75em 1em; box-sizing: border-box; text-transform: uppercase; letter-spacing: 0.2em; transition: all 0.1s ease;
}
.btn:hover, .btn:focus { background-color: #333; border: 1px solid #333; color: white;
}
#overlay { transition: opacity 0.35s ease; padding: 0em; box-sizing: border-box; opacity: 0; display: flex; align-items: center; position: absolute; background-color: rgba(0, 0, 0, 0.85); width: 1px; height: 1px; top: 0; left: 0;
}
#overlay > * { display: none;
}
input:checked + #overlay { width: 100%; height: 100%; padding: 1em; opacity: 1;
}
@media (min-width: 500px) { input:checked + #overlay { padding: 2em; }
}
@media (min-width: 900px) { input:checked + #overlay { padding: 4em; }
}
input:checked + #overlay > * { display: block;
}
.video-wrapper { box-sizing: border-box; min-width: 100%; position: relative; padding-bottom: 56.25%; /* 16:9 */ padding-top: 25px; height: 0;
}
.video-wrapper iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
CSS Only Video Lightbox - Script Codes
CSS Only Video Lightbox - Script Codes
Home Page Home
Developer Drew McConville
Username drew_mc
Uploaded August 31, 2022
Rating 3
Size 3,250 Kb
Views 36,432
Do you need developer help for CSS Only Video Lightbox?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Drew McConville (drew_mc) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!