Ravi Kumar Profile picture
Jan 18, 2022 13 tweets 5 min read Read on X
Do you know about CSS Scroll-Snap?

🧵👇
1⃣. What is CSS scroll-snap?

1. It is a CSS property that helps you to make your page more accessible to all devices.

2. Helps you to make more user-friendly websites

Example👇
2⃣. How to Implement

1. To use scroll snap on a container, its child items should be displayed inline.

2. We can use the flexbox property for that.

3. Define the scroll-snap type.

Syntax :
scroll-snap-type: none | [ x | y | block | inline | both ] [ mandatory | proximity]
3⃣. Scroll-snap type

Directions: We can give the directions for scrolling

1. scroll-snap-type-x: this will create the scrolling bar in the horizontal directions.

2. scroll-snap-type-y: this will create the scrolling bar in the vertical directions.

Example👇
4⃣ Scroll-snap type

1. Strictness: we can control the strictness of the scroll bar and the values to control scroll bare are:
mandatory | proximity

2. strictness helps to control the effectiveness of the scroll bar where sometimes scrolling doesn't happen.
5⃣ Scroll-snap-type: mandatory

mandatory is a strictness value that tells the browser to always go to a snap position when there isn’t scrolling happening.

Example👇
6⃣ Scroll-snap-type: Proximity

Proximity is a strictness value that tells the browser to go to a snap position if a scrolling action gets pretty close to a snap position.

If it’s not pretty close, then the browser shouldn’t snap and scrolling will behave normally.

Example👇
7⃣ Scroll Snapping Alignment

The child items of the scrolling container need an alignment point that they can snap to. We can use start, centre or end.

Example👇
8⃣ Scroll-Snap-Stop

Sometimes, we might need to prevent the user from accidentally bypassing some important items while scrolling. If the user scrolls too quickly, it is possible to skip some items.

Example👇
9⃣ Scroll Snap Padding

The scroll-padding shorthand property sets scroll padding on all sides, similar to how the padding property works.

Example👇
🔟Scroll Snap Margin
The scroll-margin shorthand property sets the spacing between the child items of a scrolling container. When a margin is added to an element, the scrolling will snap as per the margin.

Example👇
1⃣1⃣ Bonus💡

Use Cases For CSS Scroll Snap

1. Images List

2. Friends List

3. Avatars List

4. Full Height Sections

Example👇
Thanks for reading the whole thread♥️

if you find these threads useful, retweet for more reach!

link to first thread🔗👇

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Ravi Kumar

Ravi Kumar Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @ravikmmr

Aug 9, 2023
Top 10 VS Code Extension to Increase 10x Productivity (Free):

⬇️ Image
(1/10) Path Intellisense

— This Extension autocompletes the file names. Like tags in HTML, it autocompletes the tags. Image
(2/10) Live Server

— This Extension allows you to launch your local projects with a live reload on the browser so you don't have to constantly refresh after changes. Image
Read 12 tweets
Aug 3, 2023
Free Public APIs for Developers:

🧵 Image
1⃣ OpenWeather

🔗 https://t.co/BMtII438OIopenweathermap.org/api
Image
2⃣ The NASA APIs

🔗 https://t.co/fseHAkgWssapi.nasa.gov
Image
Read 10 tweets
Jun 6, 2023
Best Responsive Web Design Practices you should follow (save or bookmark it): Image
1/ Set The Viewport

<meta name="viewport" content="width=device-width, initial-scale=1.0"> Image
2/ Use media queries

This CSS property has a feature to enable your webpage content to adapt to different screen sizes. Image
Read 9 tweets
Jun 5, 2023
Want to Improve CSS try these Resources (Free): Source:  https://res.cloudi...
1/ CSS Tricks

🔗css-tricks.com Image
2/ CSS Author.

🔗cssauthor.com Image
Read 12 tweets
May 29, 2023
Top GitHub Repository you should definitely check out as a web developer (thread): Image
1/ Developer-roadmap

If you want to start your career in web development but don't know where to start then check out this repository you get all the details about web development.

🔗github.com/kamranahmedse/… Image
2/ FreeCodeCamp

It is a friendly community where you can learn to code for free. It has also a huge resource of video lectures or courses for a web developer.

🔗github.com/freeCodeCamp/f… Image
Read 12 tweets
May 28, 2023
Top 10 VS Code Extension to Increase 10x Productivity (Free):

⬇️ Image
1/ Path Intellisense

— This Extension autocompletes the file names. Like tags in HTML, it autocompletes the tags Image
2/ Live Server

— This Extension allows you to launch your local projects with a live reload on the browser so you don't have to constantly refresh after changes. Image
Read 12 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(