0
0
CSSmarkup~5 mins

CSS calc usage - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the CSS calc() function do?
The calc() function lets you do math inside CSS to calculate property values dynamically, like adding lengths or percentages.
Click to reveal answer
beginner
How do you write a CSS rule to set width to half the viewport width minus 50 pixels using calc()?
You write: width: calc(50vw - 50px); This means the width is half the viewport width minus 50 pixels.
Click to reveal answer
beginner
Can you mix units like percentages and pixels inside calc()?
Yes! You can combine different units like calc(100% - 20px) to get flexible layouts.
Click to reveal answer
intermediate
Why is calc() useful for responsive design?
calc() helps create sizes that adjust based on screen size and fixed values, making layouts flexible and neat on different devices.
Click to reveal answer
beginner
What is a common mistake to avoid when using calc() in CSS?
Avoid missing spaces around operators. For example, write calc(100% - 50px) not calc(100%-50px) because spaces are required.
Click to reveal answer
Which of these is a valid use of calc() in CSS?
Awidth: calc(100% - 20px);
Bwidth: calc(100%-20px);
Cwidth: calc(100%20px);
Dwidth: calc(100% +);
What units can you combine inside calc()?
AOnly pixels
BOnly percentages
CAny mix of length units like px, %, em, vw
DOnly viewport units
Why might you use calc(100% - 2rem) for padding?
ATo set padding to a fixed 2rem
BTo subtract 2rem from the full width for spacing
CTo add 2rem to the full width
DTo ignore the 2rem value
What happens if you omit spaces around operators in calc()?
ACSS ignores the calc()
BThe browser throws an error and ignores the rule
CIt still works fine
DIt doubles the value
Which CSS property is a good candidate to use calc() with?
Acolor
Bwidth
Cfont-weight
Ddisplay
Explain how the CSS calc() function helps create flexible layouts.
Think about combining percentages and pixels for screen sizes.
You got /4 concepts.
    Describe the syntax rules you must follow when writing a calc() expression in CSS.
    Focus on spacing and operator usage.
    You got /4 concepts.