Last active
September 10, 2024 11:52
-
-
Save christophengelmayer/0edd4d9b6fdeb6ff551fb80d957fd35d to your computer and use it in GitHub Desktop.
Tailwind CSS responsive Video embed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="relative" style="padding-top: 56.25%"> | |
<iframe class="absolute inset-0 w-full h-full" src="https://www.youtube-nocookie.com/embed/FMrtSHAAPhM" frameborder="0" β¦></iframe> | |
</div> |
That can even be achieved with fewer classes:
<div class="relative" style="padding-top: 56.25%"> <iframe src="https://example.com" class="absolute inset-0 w-full h-full" frameborder="0" β¦></iframe></div>
Edit: Actually, you might as well use the official @tailwindcss/aspect-ratio
plugin! π
π
That can even be achieved with fewer classes:
<div class="relative" style="padding-top: 56.25%"> <iframe src="https://example.com" class="absolute inset-0 w-full h-full" frameborder="0" β¦></iframe> </div>
Thanks for the hint. I updated the gist.
ππ» Thanks guys
Thanks!
how do you embed a local video then? and not a yt video?
What about google maps embeds?
Thanks man. This works for me. I don't even the aspect-ratio plugin for my use case
@christophengelmayer success! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! You helped me out :D