Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect ratio padding for iframe videos #60

Open
mdt2 opened this issue Nov 23, 2020 · 1 comment
Open

Aspect ratio padding for iframe videos #60

mdt2 opened this issue Nov 23, 2020 · 1 comment

Comments

@mdt2
Copy link
Contributor

mdt2 commented Nov 23, 2020

We copy/paste this code from project to project, it would be nice to have here! The 56.25% creates the 16:9 aspect ratio.

.video {
  // Creates a container with at 16:9 aspect ratio
  height: 0 !important;
  padding-bottom: 56.25% !important;
  position: relative;
  iframe {
    position: absolute;
    width: 100%;
    height: 100%;
  }
}
@zastrow
Copy link
Contributor

zastrow commented Oct 8, 2021

I like the idea of creating a mixin to accomplish this. There is already a ratio percent function in Sparkle, but I think a mixin that accomplishes this would be versatile to fit a custom class.

What would be best for this is if we can pass in ratio percentage, but default to the widescreen 56.25% value. Then the iframe should be customizeable/expandable as well.

For usage this is what I think this is what this should look like:

.my_video {
 @include ratio-block( ratio(4, 3), '.iframe')
}

I’m open to discussing the name of this function. The ratio(4, 3) is in number value, so it can use percentages or calc(), or the ratio() function. The second portion of the mixing '.iframe' would allow for passing in a string of selectors, because we may want iframe and video and some other class value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants