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

🐺If they can get press, so can you.

Friday, January 10, 2025

Calling all product businesses and designers. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

🐺Are you overwhelmed when it comes to PR?

Friday, January 10, 2025

do this. ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

#489: Web Performance

Tuesday, January 7, 2025

Instant navigation, Web Almanac 2024, INP debugging, font-face fallbacks and compression dictionaries. Issue #489 • Jan 7, 2025 • View in the browser Smashing Newsletter Hello Smashing Friends, Web

The Beautiful House That Made Mayer Rus Anxious—At First

Tuesday, January 7, 2025

View in your browser | Update your preferences ADPro Concrete Box Supreme I confess, I was a bit intimidated by the prospect of writing about the work of architect Tadao Ando for the first time in my

New Updates and a Sneak Peek into 2025

Tuesday, January 7, 2025

Both our email builder and website builder are getting significant upgrades to enhance your experience.͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌ ͏‌

🐺Get ready to get press in 2025!

Tuesday, January 7, 2025

Since you asked, we extended the sale! ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Accessibility Weekly #430: FTC Orders AccessiBe to Pay $1M

Monday, January 6, 2025

January 6, 2025 • Issue #430 View this issue online or browse the full issue archive. Featured: FTC orders AI accessibility startup AccessiBe to pay $1M for misleading advertising "The US Federal

Getting ready for 2025

Sunday, January 5, 2025

Issue 227: Key focuses in the new year ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏ ͏

Want to Scale Your Firm in 2025? Start Here

Thursday, January 2, 2025

View in your browser | Update your preferences ADPro Build Your Best Team Yet A new calendar year presents an opportunity to wipe the slate clean, and your approach, whether slapdash or carefully

Our Must-Reads of 2024

Tuesday, December 31, 2024

View in your browser | Update your preferences ADPro Year in Review Well, we made it. It's the last day of 2024, so today, we're taking a walk down memory lane to bring you some of our