-
Hajipur, Bihar, 844101
CSS Math Functions allow you to perform dynamic calculations inside your CSS properties. These functions help build responsive, scalable, and conditional layouts.
calc()
min()
max()
clamp()
calc()
– Calculate Dynamic Valueswidth: calc(100% - 60px);
Used to subtract, add, multiply, or divide values dynamically.
Supported operations:
+
(addition)
-
(subtraction)
*
(multiplication)
/
(division)
min()
– Choose the Smallest Valuewidth: min(100%, 500px);
Chooses the smallest value between the two.
max()
– Choose the Largest Valueheight: max(200px, 50vh);
Chooses the largest value between the two.
clamp()
– Set Minimum, Preferred, and Maximumfont-size: clamp(14px, 2vw, 24px);
Resizes between a minimum, preferred, and maximum range.
✅ Makes layout flexible
✅ Avoids hardcoding media queries
✅ Enables better responsiveness
✅ Cleaner and dynamic styling logic
.container {
width: calc(100% - 2rem);
padding: clamp(1rem, 2vw, 3rem);
font-size: min(5vw, 20px);
}
Q1. Set a container width to 100% - 200px
using calc()
.
Q2. Use min()
to limit image width between 100% and 300px.
Q3. Use max()
to ensure card height is at least 50vh.
Q4. Apply clamp()
to font-size from 12px to 24px.
Q5. Add padding using calc(2em + 10px)
.
Q6. Use calc()
to center a div horizontally with margin.
Q7. Create a sidebar using width: calc(30% + 100px)
.
Q8. Use min()
in a responsive grid layout.
Q9. Set margin using clamp()
to make it responsive.
Q10. Multiply value using calc(2 * 1em)
for line-height.
Q1: Which function performs calculations in CSS?
Q2: Which math function chooses the smallest value?
Q3: What does clamp(12px, 4vw, 32px) do?
Q4: What is the result of width: calc(100% - 100px);?
Q5: Which operator is NOT supported in calc()?
Q6: What does min(400px, 90vw) return on a small screen?
Q7: Which function is ideal for responsive font sizes?
Q8: What is the purpose of max() in CSS?
Q9: Which function can define a flexible yet constrained value?
Q10: Which function would you use to calculate padding like 10px + 2em?