Smashing Magazine - Smashing Newsletter #276: CSS Edition

Preventing layout shifts with CSS Grid, clamp(), custom list markers and fixed haders and jump links with scroll-margin. Issue #276 Tue, Nov. 24, 2020 View in the browser 💨

Smashing Newsletter

Dear Friends,

The subject of the newsletter today is CSS — very much my favorite subject! We have plenty of CSS-related material in our Guide to CSS Layout and a good number of useful articles that we’ve published in the past (e.g. “How To Learn CSS” would be a good place to start).

But in case you’re looking to dive in even more into the world of CSS, there’s still time to book one of the final remaining tickets for our workshop with Andy Bell on “Building A Design System With CSS”. He’ll be showing you how to create a resilient and scalable design system using CUBE CSS, and so much more!

Also, we have just announced that this December 17, we are organizing another community-based Smashing Meets event! This time, it’ll be a nice and cozy ‘Happy Holidays’ edition to celebrate the holiday season of this interesting year with a few hours of Smashing fun! There will be three talks and some fun side events, too. Tickets are only 10 USD, and our Smashing Members get in for free.

Smashing Meets Happy Holidays Edition

I hope that our American readers have a good Thanksgiving, and while it may be a bit different compared to the previous years, hopefully you’ll still manage to celebrate and have some time to relax.

Stay safe,
Rachel Andrew (@rachelandrew)


Table of Contents

1. Preventing Layout Shifts With CSS Grid
2. Fluid Typography With clamp()
3. New Front-End & UX Workshops
4. A Clever Solution For Autogrowing Textareas
5. Custom List Markers
6. Fixing Headers And Jump Links
7. New On Smashing Job Board
8. Our Current Most Popular Articles

1. Preventing Layout Shifts With CSS Grid

It’s no news that CSS Grid is a fantastic tool to build complex layouts. But did you know that it can help you prevent layout shifts, too? When Hubert Sablonnière discovered a layout shift problem with a toggling state on a UI component he worked on, he came up with a solution: the “Anti Layout Shift Grid Stacking Technique”.

Prevent layout shifts with CSS grid stacks

Compared to solving the layout shift with absolute positioning, Hubert’s Grid-based technique supports complex situations that require more than two panels. Another benefit: You don’t need to assume which panel should guide the size of the whole component. If you want to dive in deeper, Hubert wrote up everything you need to know to prevent both vertical and horizontal shifts in a practical blog post. (cm)


2. Fluid Typography With clamp()

When it comes to fluid scaling, CSS has some exciting new features: clamp(), min(), and max(). They cap and scale values as the browser grows and shrinks. min() and max() return the respective minimum and maximum values at any given time while clamp lets you you pass in both a minimum and maximum plus a preferred size for the browser to use.

Clamp

As Trys Mudford points out, clamp() comes in particularly handy when you want broadly fluid typography without being 100% specific about the relationship between the varying sizes. In his in-depth article about the new feature, he shares valuable hands-on tips for using clamp() effectively. (cm)


3. New Front-End & UX Workshops

We’ve been running online workshops since April this year, and it’s always an incredible experience with wonderful attendees from all over the world coming together to learn something together. That’s Smashing Workshops: live 2.5h-sessions with practical examples, video recordings and a friendly Q&A.

Smashing Online Events
Live and interactive: 2.5h-sessions, spanning across days or weeks.

We’ve just announced our new front-end & UX workshops on front-end in 2021, forms, SVG animation, CSS and HTML email. There are still some early-birds left, with a lil’ friendly discount, so take a look and perhaps join us as well.


4. A Clever Solution For Autogrowing Textareas

There’s no native solution for an autogrowing <textarea> that expands in height as much as it needs to in order to contain the current value. Based on an idea by Stephen Shaw, Chris Coyier shares a very clever workaround for autogrowing textareas that achieves the desired effect until we get something better and native.

The Cleanest Trick for Autogrowing Textareas

The trick is that you replicate the content of the <textarea> in an element that can auto-expand height, and match its sizing. Then hide the replica visually. Whichever of the children is tallest will push the parent to that height, and the other child will follow. The minimum height of the <textarea> serves as the base height, but as soon as the replicated text element grows taller, everything will grow taller with it. Nice! (cm)


5. Custom List Markers

There are ordered lists and unordered lists, each of them giving us the standard styling we expect. However, there’s more to lists than that, and thanks to CSS we have more styling options than you may think. How about starting a list of pros and cons with thumbs up and thumbs down emoji, for example?

Custom Emoji Markers

Lea Verou did exactly that with the help of ::marker { content: var(--marker); }. The ::marker pseudo-element allows us to have custom markers (emoji, for example) with just one property, either on the <li> or an ancestor. Browser support for the feature is constantly improving. If you want to learn more about markers, counters, and how to tailor CSS lists to your need, Rachel Andrew’s article takes a closer look at the CSS Lists specification and the possibilities it brings along. (cm)


From our sponsor

Build In-Demand Skills In Northwestern’s Online MS In Information Design And Strategy

Work at the Intersection of Data, Design and Technology. Earn your master’s degree online at Northwestern Information Design and Strategy.
Earn your master’s degree online.


6. Fixing Headers And Jump Links

Jump links in combination with fixed headers can cause quite some frustration. Maybe you’ve run into the same issue before: When clicked, your jump link takes you to the desired element, but a fixed header is hiding it. In the past, wild hacks were required to solve the issue. Luckily, there’s now a straightforward and well-supported CSS solution.

Fixed Headers And Jump Links

The trick: scroll-margin-top. Assign it to your headers, and the position: fixed header won’t get into their way anymore when you navigate to them with a jump link. A short line of code that makes a huge difference. (cm)


7. New On Smashing Job Board


8. Our Current Most Popular Articles


This newsletter issue was written and edited by Cosima Mielke (cm), Vitaly Friedman (vf), Rachel Andrew (ra) and Iris Lješnjanin (il).


Sent to truly smashing readers via Mailchimp.
We sincerely appreciate your kind support. You
rock.

Follow us on Twitter Join us on Facebook


unsubscribe update preferences view in your browser


Older messages

Making Sense Of TypeScript, in 50 Lessons.

Tuesday, November 17, 2020

Our new book on TypeScript, how it works, and how you can make it work for you. With code walkthroughs, hands-on examples and common gotchas. TypeScript in 50 Lessons: TypeScript, from start to finish.

Smashing Newsletter #275: React Rendering, JavaScript Debugging, CSS and SVG

Tuesday, November 17, 2020

With server-side rendering, JavaScript debugging, free CSS/SVG background patterns and how to avoid user frustrations. Issue #275 • Tue, Nov. 17, 2020 • View in the browser 💨 Smashing Newsletter Dear

New Smashing Workshops on Front-End & UX (Jan–Feb 2021)

Friday, November 13, 2020

Just in: new online workshops for 2021 on front-end, SVG animation, HTML email and CSS. With Cassie Evans, Vitaly Friedman, Rachel Andrew and Adam Silver. New online workshops on front-end, HTML emails

Smashing Newsletter #273: Waterfalls, Flame Charts and Inline Validation

Tuesday, November 3, 2020

With performance articles and tools, data visualization, patterns and designing a better inline form validation. Issue #273 • Tue, Nov. 3, 2020 • View in the browser 💨 Smashing Newsletter Dear Friend,

Smashing Newsletter #272: Dark Mode, Onboarding and Checkout UX

Tuesday, October 27, 2020

With design guidelines to design for dark mode, video player UI, mobile app onboarding and eCommerce checkout UX. Issue #272 • Tue, Oct. 27, 2020 • View in the browser 💨 Smashing Newsletter Dear Friend

You Might Also Like

Pierce & Ward’s Secret Sources, Business Advice You Can’t Afford to Miss, and More

Friday, April 19, 2024

View in your browser | Update your preferences ADPro “Minimalism is not my strong suit.” So says Emma Roberts, the muse behind AD's May cover story. (Celebrities—they're just like us!)

World Press Photo Contest, Speedometer 3.0, Anchor Position, Sliding Frame, Meta Llama 3

Friday, April 19, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar April 19 2024 The World Press Photo Contest Documents War,

Car UX, DevTools Tips, CSS Patterns, iOS404, Internet Cables

Thursday, April 18, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar April 18 2024 Steering the future: a new vision for car UX

Big Tents, Pistachio Palettes, and Other Late-Breaking Milan Discoveries

Wednesday, April 17, 2024

View in your browser | Update your preferences We've had a remodel! From now on, you'll be hearing from AD PRO in your inbox twice a week—once with a deep dive into trends to watch and subjects

163 / Dieter Rams inspired Framer components, America's national parks and more free resources…

Wednesday, April 17, 2024

Product Disrupt Logo Product Disrupt Half-Monthly Apr 2024 • Part 1 View in browser Welcome to Issue 163! I'm comfortable talking to a human on camera, but talking at the camera, not so much. The

Logo System, BCWA Identity, War Robots, 84—24, 19th-Century Atlas

Wednesday, April 17, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar April 17 2024 Logo System: Explore 400+ logo designs logosystem

Emma Roberts's Home: AD100 Firm Pierce & Ward Share Their Secret Sources

Tuesday, April 16, 2024

Plus, the best exterior house colors View in your browser | Update your preferences Architectural Digest AD PRO Logo exterior of two residential buildings painted with blue trim with a brick patio and

#452: Design Workflow

Tuesday, April 16, 2024

How to choose the right idea, navigate difficult conversations and communicate design. Issue #452 • Apr 16, 2024 • View in the browser Smashing Newsletter Iyi akşamlar Smashing Friends, Design workflow

Mario & Pareto, faces.js, Sleep vs Blog, Dark Mode, DOM Folding

Tuesday, April 16, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar April 16 2024 Mario meets Pareto mayerowitz.io Discover how to

Gap, Teenagers, Artistic Intelligence, Should Designers Code, CSS in RSCs

Tuesday, April 16, 2024

The 5 best design links, every day. Curated by a selection of great editors. Email not displaying properly? View browser version. Sidebar April 15 2024 Gap is the new Margin frontendmasters.com In 2020