Jacob V. Jacob V. - 1 month ago 25
CSS Question

Converting pixels into percentages using CSS

I have a rectangle, the width is

125px
and the height is
48px
. I am trying to make the rectangle 5% bigger. How can I get increase the rectangle by 5%, while knowing the width and height in pixels.

Answer

CSS's calc function is your friend:

.rect {
    width: calc(125px * 105%);
    height: calc(48px * 105%);
}