I have an absolutely positioned background video that's been "cropped" - meaning the top and bottom 20% or so is hidden.
Here's a link to what I've built (hero area): http://pchapman-sandbox.dev.vuforia.com/vuforia-landing/
In the center of this video, at several points it shows a phone, with important video content in the phone. I need that phone to stay centered within this cropped area.
Problem: currently I've written 7 media queries with a mild transition. However, at various widths the centering is off and it's a clunky solution.
The height of the "cropping" area ranges from 420px
to 460px
The current control on <video>
, starts thus:
top: -35vh;
@media screen and (min-width: 2000px) and (max-width: 2400px) {
top: -31vh !important;
transition: top 2s ease-in;
}
// multiple media queries down to...
@media screen and (max-width: 980px) {
top: 0 !important;
transition: top 2s ease-in;
}
I would love the option of a calc()
function; to calculate the top
value based on the width of the browser. I've checked a bunch of links including controlling padding via height and looked at SASS Poly Fluid Sizing but I can't make anything work and am fast reaching frustration point. Pluse,I don't think I understand calc()
so well, what values go where.
Is this the right approach? Should I use something else instead? I'd prefer a CSS solution if possible.
Thank you for any help!