How to make div width 100% minus fixed amount of pixels with CSS?

Spread the love

Sometimes, we want to make div width 100% minus fixed amount of pixels with CSS.

In this article, we’ll look at how to make div width 100% minus fixed amount of pixels with CSS.

How to make div width 100% minus fixed amount of pixels with CSS?

To make div width 100% minus fixed amount of pixels with CSS, we use calc.

For instance, we write

.calculated-width {
  width: calc(100% - 100px);
}

to make the elements with calculated-width have width 100% minus 100px with calc(100% - 100px).

Conclusion

To make div width 100% minus fixed amount of pixels with CSS, we use calc.

Leave a Reply

Your email address will not be published.