I'm creating a website using a builder (Divi). I just need a bit of CSS code to scale and position one element (a video), but the only code I know is JS. I was wondering if anyone can help me translate it into CSS. Here's the JS code:
var browserW = window.innerWidth;
var browserH = window.innerHeight;
var yPosOrigin = ORIGINAL POSITION;
var aspect = browserW/browserH;
if (aspect > 1 && aspect < 2) {
vidW = browserH*2;
} else {
vidW = linear(aspect, 1, 2, (browserW*2), browserW);
}
vidSca = vidW/1920*100;
if (aspect > 2) {
yPos = yPosOrigin+((browserH-(960*(vidSca/100)))/2);
} else {
yPos = yPosOrigin;
}
The three first lines are just setting variables. In the end, I want the video to be scaled at vidSca(%) and the vertical position adjusted by yPos (pixels).
Any advice? Thanks!
This may be a silly question,
This may be a silly question, but why do you need to do it with CSS? Can you not use your existing Javascript to achieve what you need?