CSS Can Do That Too

Rate this content
Bookmark

CSS has evolved and grown immensely since it was first introduced back in 1996. There was a time back then when CSS was not even meant for doing layouts, but that time has long past. Today, web layouts are practically synonymous with CSS. In addition to that, CSS can now be used to build things that used to only be feasible with Javascript. This talk will showcase a few of such features and explain how to build them yourself.

FAQ

JS Nation is the biggest JavaScript conference held in the cloud, featuring a variety of talks and sessions focused on JavaScript and related technologies.

Hui Jing is a front-end developer at Shopify, who spoke at JS Nation about advancements in CSS that simplify tasks previously requiring JavaScript.

The talk discussed using media queries for granular control of text sizing, a combination of CALC and viewport units for scalable font sizes, and the CSS clamp function to set a scalable range with defined minimum and maximum values.

The CSS clamp function allows setting a font size within a defined range, using three parameters: a minimum value, a preferred value, and a maximum value. It helps text to grow and shrink based on the viewport but within the specified limits.

CSS scroll snapping allows elements to snap to a specific point as you scroll. It uses properties like 'scroll snap type' for the container and 'scroll snap align' for the child elements, to control the snapping behavior.

Position sticky in CSS allows an element to switch between relative and fixed positioning depending on the scroll position. It requires a specified offset value to determine when the sticking should occur.

As of the latest updates, CSS scroll snapping enjoys about 94% browser support, and CSS math functions have around 91% support. These features are widely supported except for some older browsers.

CSS Masonry is a layout technique that allows grid items to be laid out in an optimal manner without strict rows or columns, similar to masonry walls. It's currently still in the experimental phase in browsers like Firefox.

Chen Hui Jing
Chen Hui Jing
22 min
11 Jun, 2021

Comments

Sign in or register to post your comment.

Video Summary and Transcription

This Talk is about CSS techniques that can simplify web development and eliminate the need for JavaScript. It covers topics such as responsive typography, flexible font sizing, CSS math functions, scroll snapping, sticky elements, and CSS masonry layout. The speaker emphasizes the importance of understanding how sticky elements work and highlights the potential bugs that can occur. CSS Masonry layout is discussed as a native solution for creating masonry grids in the browser. Overall, CSS provides flexible solutions for web styling and is an exciting tool for developers.

Available in Español: CSS También Puede Hacer Eso

1. Introduction to CSS and Responsive Topography

Short description:

Hello, everyone. This is the first time I'm participating in JS Nation and I hope you've all had a great time so far. JS Nation is the biggest JavaScript conference in the cloud, so naturally I'm going to be talking about CSS! Specifically, things that we used to need JavaScript for, but can now be simplified using CSS alone. My name is Hui Jing. I'm a front-end developer at Shopify. This is going to be a rather short 20-minute talk, so think of this as more of a, ooh, that's nice, I've learned new information today kind of thing. Let's start off with responsive topography. The web is fun because you cannot control the environment in which your audience views your creations. For textual content on the web, the legibility and readability are key concerns. Web typography has always been a focus, and as newer CSS properties become available, techniques have been continually refined. The first option is media queries, which offer granular control over the size of text. The second option is CALC.

Hello, everyone. This is the first time I'm participating in JS Nation and I hope you've all had a great time so far. I believe it's the third day, so plenty of amazing talks already. Now, hang in there. Almost done.

Now, JS Nation is the biggest JavaScript conference in the cloud, so naturally I'm going to be talking about CSS! Specifically, things that we used to need JavaScript for, but can now be simplified using CSS alone. So a quick introduction. My name is Hui Jing. I'm fairly simple enough that these emojis right here paint a pretty comprehensive picture of who I am as a human being. I happen to be Chinese, and if you're unfamiliar with Chinese names, our family names come first and the first name comes after, so Hui Jing is me. I'm currently a front-end developer at Shopify. Day job, important. Have to pay the bills. So this is going to be a rather short 20-minute talk, so I don't expect people to instantly pick up everything that I'm trying to cover here. Think of this as more of a, ooh, that's nice, I've learned new information today kind of thing. And if you ever come meet a use-case where these solutions work for you, then you can take your time to go and understand them at a deeper level at your own time.

So let's start off with responsive topography. Now when I say this, some of you might think I have a weird mindset, but to me, the web is fun because you cannot control the environment in which your audience views your creations. So it's kind of like you built something, but you're not sure how other people are going to see it. That's what makes it exciting. But for textual content on the web, there is still a key concern, regardless of what type of design or whatever you're doing, is the legibility and readability of your textual content. So web typography has always been a focus for many people. And there have been a number of techniques that have been developed over the years, and as newer CSS properties become available, a lot of these techniques have been continually refined.

So let's do this in the browser, demo time. The first option we have is just straight up media queries, and even though it seems fairly basic, you can also look at it as this is the most flexible option, even today, because you have really granular control over the size of which you want your text to change at whatever viewport that you specify. So in this example here, I've arbitrarily put in 42 and 54 as the breakpoints, but it's really very customizable. So let's do this DevTools thing. So as the viewport changes, you can see you can get your text to change alongside it, and just having a very basic series of media queries, you can be very granular. I can see how people feel that this might get a bit tedious if there are many different viewports you want to take care of. So the second option that I'm showing here, which is CALC.

2. CSS Locks: Flexible Font Sizing

Short description:

A combination of CALC and viewport units. This technique allows font sizes to grow and shrink with the viewport width, providing smooth scaling between the defined minimum and maximum sizes. It's known as CSS locks.

A combination of CALC and viewport units. This technique was created by Mike Rithmuller, I believe, back in 2015. It has a couple of names, I think. Some people call it CSS locks, you might have seen it covered in other articles. Basically, this technique allows your font sizes to grow and shrink with the viewport width. This is the viewport units here. And if I'll show you, you can see that it's kind of a gradual grow and shrink. But then, it doesn't... at this point, it stops shrinking, somewhere along this point, it stops growing. So that's why, again, it's a combination of media queries CALC and viewport units, because there's a cap on the maximum and minimum sizes. But anything between that, the font size will scale smoothly. I guess that's why they call CSS locks, because you're locking the minimum and the maximum size.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Scaling Up with Remix and Micro Frontends
Remix Conf Europe 2022Remix Conf Europe 2022
23 min
Scaling Up with Remix and Micro Frontends
Top Content
Do you have a large product built by many teams? Are you struggling to release often? Did your frontend turn into a massive unmaintainable monolith? If, like me, you’ve answered yes to any of those questions, this talk is for you! I’ll show you exactly how you can build a micro frontend architecture with Remix to solve those challenges.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
Making JavaScript on WebAssembly Fast
JSNation Live 2021JSNation Live 2021
29 min
Making JavaScript on WebAssembly Fast
Top Content
JavaScript in the browser runs many times faster than it did two decades ago. And that happened because the browser vendors spent that time working on intensive performance optimizations in their JavaScript engines.Because of this optimization work, JavaScript is now running in many places besides the browser. But there are still some environments where the JS engines can’t apply those optimizations in the right way to make things fast.We’re working to solve this, beginning a whole new wave of JavaScript optimization work. We’re improving JavaScript performance for entirely different environments, where different rules apply. And this is possible because of WebAssembly. In this talk, I'll explain how this all works and what's coming next.
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
As developers, we spend much of our time debugging apps - often code we didn't even write. Sadly, few developers have ever been taught how to approach debugging - it's something most of us learn through painful experience.  The good news is you _can_ learn how to debug effectively, and there's several key techniques and tools you can use for debugging JS and React apps.
Webpack in 5 Years?
JSNation 2022JSNation 2022
26 min
Webpack in 5 Years?
Top Content
What can we learn from the last 10 years for the next 5 years? Is there a future for Webpack? What do we need to do now?
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.

Workshops on related topic

Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
React Day Berlin 2022React Day Berlin 2022
86 min
Using CodeMirror to Build a JavaScript Editor with Linting and AutoComplete
Top Content
WorkshopFree
Hussien Khayoon
Kahvi Patel
2 authors
Using a library might seem easy at first glance, but how do you choose the right library? How do you upgrade an existing one? And how do you wade through the documentation to find what you want?
In this workshop, we’ll discuss all these finer points while going through a general example of building a code editor using CodeMirror in React. All while sharing some of the nuances our team learned about using this library and some problems we encountered.
Testing Web Applications Using Cypress
TestJS Summit - January, 2021TestJS Summit - January, 2021
173 min
Testing Web Applications Using Cypress
WorkshopFree
Gleb Bahmutov
Gleb Bahmutov
This workshop will teach you the basics of writing useful end-to-end tests using Cypress Test Runner.
We will cover writing tests, covering every application feature, structuring tests, intercepting network requests, and setting up the backend data.
Anyone who knows JavaScript programming language and has NPM installed would be able to follow along.
Build a powerful DataGrid in few hours with Ag Grid
React Summit US 2023React Summit US 2023
96 min
Build a powerful DataGrid in few hours with Ag Grid
WorkshopFree
Mike Ryan
Mike Ryan
Does your React app need to efficiently display lots (and lots) of data in a grid? Do your users want to be able to search, sort, filter, and edit data? AG Grid is the best JavaScript grid in the world and is packed with features, highly performant, and extensible. In this workshop, you’ll learn how to get started with AG Grid, how we can enable sorting and filtering of data in the grid, cell rendering, and more. You will walk away from this free 3-hour workshop equipped with the knowledge for implementing AG Grid into your React application.
We all know that rolling our own grid solution is not easy, and let's be honest, is not something that we should be working on. We are focused on building a product and driving forward innovation. In this workshop, you'll see just how easy it is to get started with AG Grid.
Prerequisites: Basic React and JavaScript
Workshop level: Beginner
0 to Auth in an Hour Using NodeJS SDK
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Asaf Shen
Asaf Shen
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
Build a Powerful Datagrid With AG Grid
React Summit 2024React Summit 2024
168 min
Build a Powerful Datagrid With AG Grid
WorkshopFree
Brian Love
Brian Love
Does your React app need to efficiently display lots (and lots) of data in a grid? Do your users want to be able to search, sort, filter, and edit data? AG Grid is the best JavaScript grid in the world and is packed with features, highly performant, and extensible. In this workshop, you’ll learn how to get started with AG Grid, how we can enable sorting and filtering of data in the grid, cell rendering, and more. You will walk away from this free 3-hour workshop equipped with the knowledge for implementing AG Grid into your React application.
JavaScript-based full-text search with Orama everywhere
Node Congress 2023Node Congress 2023
49 min
JavaScript-based full-text search with Orama everywhere
Workshop
Michele Riva
Michele Riva
In this workshop, we will see how to adopt Orama, a powerful full-text search engine written entirely in JavaScript, to make search available wherever JavaScript runs. We will learn when, how, and why deploying it on a serverless function could be a great idea, and when it would be better to keep it directly on the browser. Forget APIs, complex configurations, etc: Orama will make it easy to integrate search on projects of any scale.