How do you feel about aspect ratio utilities? For example a class could be like:
padding-top: 56.25%;
padding-top: 75%
padding-top: 100%
Video that maintains 16:9 aspect ratio, responsively. One could also mix it with responsive classes and switch src to a 4:3 and set aspect ratio to that as well.
<div class="aspect-16:9 w-full relative">
<iframe src="some-16:9-video-url" class="absolute w-full h-full"></iframe>
</div>
Sadly, one has to apply some positioning, and also width + height to the child for this to work.
One could also automatically apply the relative position, and full width styling to any aspect utility. Maybe even add another utility like .aspect-child.
<div class="aspect-16:9">
<img src="/images/photoshoot-16-9.jpg" class="aspect-child" />
</div>
I have some doubts about this, considering it feels a little more like a minor component rather than an utility. I totally respect if this is not something that needs to be added to Tailwind core, I just felt like it could potentially add some value. 馃憤
Duplicate of #384
I use this sort of thing on my own projects too but want to hold off on adding it to core right now. There's a plugin out there though: https://github.com/webdna/tailwindcss-aspect-ratio
Most helpful comment
I use this sort of thing on my own projects too but want to hold off on adding it to core right now. There's a plugin out there though: https://github.com/webdna/tailwindcss-aspect-ratio