From the course: Mastering Web Developer Interview Code

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

How do you use calc() in CSS?

How do you use calc() in CSS?

- [Instructor] Calc is a feature that lets you perform mathematical calculations right in your CSS. It can be really useful when writing layout code because it can make things a lot clearer. So let's take a look at how it works. Now, the first thing you need to know about calc is that it has fantastic browser support. Even down to Internet Explorer nine. And that's great because it means that you can use it today unless you're planning on working with older browsers. Now, if you do, you do need to use something like post CSS or something that will translate your CSS to work in older browsers. One of the cool features in calc is that you can mix and match units. So that you can ask for a percentage unit, but then subtract a pixel size from the percentage size. Which is something you can't use with a lot of other pre-processors. One thing you do have to watch out for is that the plus and minus operators have to be surrounded…

Contents