From the course: CSS Toolkit: Tips and Techniques for Layout and Styling
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Responsive sizing with min(), max(), and clamp() - CSS Tutorial
From the course: CSS Toolkit: Tips and Techniques for Layout and Styling
Responsive sizing with min(), max(), and clamp()
- [Instructor] With responsive design, sometimes text and layouts lack consistency across devices. For example, you might have a headline that's perfectly sized for desktop, but it looks massive on mobile. Or you might get paragraphs that feel really cramped on one screen, but the line height is way too much on another, et cetera. As developers, we have to make decisions about font sizes and layouts at different screen sizes, and we've traditionally used media queries to solve for this, but it's not the most flexible approach. Take this example. We have our mobile default font size inheriting 20 pixels from the root element here. And then we have a media query that says, hey, when we get to a certain width, let's bump the font size up to 1.3 rem. This setup works, but it forces an abrupt jump between sizes rather than smooth scaling. That's where min, max, and clamp come in. So first I'm going to get rid of this media query because we don't need that anymore. So let's start with the…
Contents
-
-
-
-
-
(Locked)
Understanding px, em, and rem units3m 3s
-
(Locked)
Setting optimal line lengths with the ch unit2m 20s
-
(Locked)
Responsive sizing with min(), max(), and clamp()5m 57s
-
(Locked)
Making sense of the line-height property3m 6s
-
(Locked)
Balancing text wrapping for better readability2m 41s
-
(Locked)
Truncating text length and number of lines of text4m 17s
-
(Locked)
Style text selection and highlighting5m 23s
-
(Locked)
Filling text with a gradient or image3m 51s
-
(Locked)
-
-
-