Class 6 Exam  >  Class 6 Notes  >  CSS for Beginners  >  CSS Math Functions

CSS Math Functions | CSS for Beginners - Class 6 PDF Download

The CSS math functions allow mathematical expressions to be used as property values. Here, we will explain the calc(), max() and min() functions.

The calc() Function


The calc() function performs a calculation to be used as the property value.

CSS Syntax


calc(expression)
CSS Math Functions | CSS for Beginners - Class 6
Let us look at an example:
Example
Use calc() to calculate the width of a <div> element:

#div1 {

  position: absolute;

  left: 50px;

  width: calc(100% - 100px);

  border: 1px solid black;

  background-color: yellow;

  padding: 5px;

}

The max() Function


The max() function uses the largest value, from a comma-separated list of values, as the property value.

CSS Syntax


max(value1, value2, ...)
CSS Math Functions | CSS for Beginners - Class 6
Let us look at an example:
Example
Use max() to set the width of #div1 to whichever value is largest, 50% or 300px:

#div1 {

  background-color: yellow;

  height: 100px;

  width: max(50%, 300px);

}

The min() Function


The min() function uses the smallest value, from a comma-separated list of values, as the property value.

CSS Syntax


min(value1, value2, ...)
CSS Math Functions | CSS for Beginners - Class 6
Let us look at an example:
Example
Use min() to set the width of #div1 to whichever value is smallest, 50% or 300px:

#div1 {

  background-color: yellow;

  height: 100px;

  width: min(50%, 300px);

}

All CSS Math Functions


CSS Math Functions | CSS for Beginners - Class 6

The document CSS Math Functions | CSS for Beginners - Class 6 is a part of the Class 6 Course CSS for Beginners.
All you need of Class 6 at this link: Class 6
10 videos|41 docs|23 tests

Top Courses for Class 6

10 videos|41 docs|23 tests
Download as PDF
Explore Courses for Class 6 exam

Top Courses for Class 6

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Exam

,

shortcuts and tricks

,

Free

,

Summary

,

Sample Paper

,

CSS Math Functions | CSS for Beginners - Class 6

,

practice quizzes

,

MCQs

,

pdf

,

Objective type Questions

,

mock tests for examination

,

Important questions

,

ppt

,

Previous Year Questions with Solutions

,

past year papers

,

video lectures

,

Semester Notes

,

CSS Math Functions | CSS for Beginners - Class 6

,

study material

,

Viva Questions

,

CSS Math Functions | CSS for Beginners - Class 6

,

Extra Questions

;