Responsive no-jQuery pure JS/CSS Lightbox for iframes, no dependencies, customizeable aspect ratio, 4 kb unminified source code, with demo
https://cdn.jsdelivr.net/gh/englishextra/iframe-lightbox@latest/iframe-lightbox.min.js
https://cdn.jsdelivr.net/gh/englishextra/iframe-lightbox@latest/iframe-lightbox.min.css
https://unpkg.com/iframe-lightbox@latest/iframe-lightbox.js
https://unpkg.com/iframe-lightbox@latest/iframe-lightbox.css
npm install iframe-lightbox
bower install iframe-lightbox
class
is not required. They are used here to select elements. You may use some other method for elements selection.
data-src
is required, and contains URL of your content.
data-padding-bottom
is optional, and can be used to change default 16/9 Aspect Ratio to the one of yours with the formula: a percentage value of height/width*100
.
For instance, HD would be: 9 / 16 * 100 + "%"
So, for YouTube or Vimeo, data-padding-bottom="56.25%"
would be enough.
For SoundCloud embedded player via iframe, use: data-padding-bottom="166px"
<a href="https://www.youtube.com/watch?v=KK9bwTlAvgo"
class="iframe-lightbox-link"
data-src="https://www.youtube.com/embed/KK9bwTlAvgo?autoplay=1"
data-padding-bottom="56.25%">YouTube</a>
<a href="https://vimeo.com/28629415"
class="iframe-lightbox-link"
data-src="https://player.vimeo.com/video/28629415?autoplay=true"
data-padding-bottom="56.25%">Vimeo</a>
<a href="https://soundcloud.com/fatcat-demo/trixicles-and-the-other-one"
class="iframe-lightbox-link"
data-src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/317031598&auto_play=false&hide_related=false&show_comments=true&show_user=true&show_reposts=false&visual=true"
data-padding-bottom="166px">SoundCloud</a>
Inspired by squeral/lightbox, and available under MIT License