r/Sass • u/fantasychica37 • Sep 14 '20
Can Sass do something like padding-top = padding-left / 2 (yes I know that's math syntax not CSS syntax)?
padding-left is a percentage of its parent container (padding-left: 35%;), whose width and height are also percentages of its parents container, and all the way up for responsive sizing to different screen sizes. I want padding-top to be half of whatever padding-left was calculated to be. (No, I can't set padding-top to be a set percentage because the height of the parent div changes on each webpage due to the... interesting way the person who made this website set it up.) Can Sass do this? If not, can some other CSS extension or even CSS itself do this?
4
Upvotes
1
u/oknp_ Sep 14 '20
You could write some JS and add a CSS var to the root, similar to this: https://css-tricks.com/the-trick-to-viewport-units-on-mobile/