Categories
CSS

How to set width/height as a percentage minus pixels with CSS?

Spread the love

To set width/height as a percentage minus pixels with CSS, we use calc.

For instance, we write

div {
  height: calc(100% - 18px);
}

to set the div’s height to 100% minus 18px with calc.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *