- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Selectors
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - scroll-snap-align Property
CSS scroll-snap-align property specifies how a snapped element is positioned within its snap container. It takes two values, the first for the block axis and the second for the inline axis.
Possible Values
-
none − The snapped element is not aligned to the snap container's snapport.
-
start − The snapped element's snap point is aligned to the start of the snap container's snapport.
-
end − The snapped element's snap point is aligned to the end of the snap container's snapport.
-
center − The snapped element's snap point is aligned to the center of the snap container's snapport.
The snapport is the area of the scroll container to which the snap areas are aligned.
Applies to
All the HTML elements.
DOM Syntax
object.style.scrollSnapAlign = "none|start|end|center";
CSS Scroll Snap Align - None Value
The following example demonstrates of how to use the scroll-snap-align: none property −
<html> <head> <style> .scroll-container { display: flex; width: 350px; height: 200px; overflow-x: auto; overflow-y: hidden; } .scrolling-section1, .scrolling-section2, .scrolling-section3 { flex: 0 0 auto; width: 300px; height: 200px; scroll-snap-align: none; } .scrolling-section1 { background-color: rgb(220, 235, 153); } .scrolling-section2 { background-color: rgb(230, 173, 218); } .scrolling-section3 { background-color: rgb(176, 229, 238); } </style> </head> <body> <div class="scroll-container"> <div class="scrolling-section1">scroll-snap-align: none</div> <div class="scrolling-section2">scroll-snap-align: none</div> <div class="scrolling-section3">scroll-snap-align: none</div> </div> </body> </html>
CSS Scroll Snap Align - Start Value
The following example demonstrates of how to use the scroll-snap-align: start property −
<html> <head> <style> .scroll-container { display: flex; width: 350px; height: 200px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; } .scrolling-section1, .scrolling-section2, .scrolling-section3 { flex: 0 0 auto; width: 300px; height: 200px; scroll-snap-stop: always; } .scrolling-section1 { background-color: rgb(220, 235, 153); scroll-snap-align: start; } .scrolling-section2 { background-color: rgb(230, 173, 218); } .scrolling-section3 { background-color: rgb(176, 229, 238); } </style> </head> <body> <div class="scroll-container"> <div class="scrolling-section1">scroll-snap-align: start</div> <div class="scrolling-section2">scroll-snap-align</div> <div class="scrolling-section3">scroll-snap-align</div> </div> </body> </html>
CSS Scroll Snap Align - Center Value
The following example demonstrates of how to use the scroll-snap-align: center property −
<html> <head> <style> .scroll-container { display: flex; width: 350px; height: 200px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; } .scrolling-section1, .scrolling-section2, .scrolling-section3 { flex: 0 0 auto; width: 300px; height: 200px; scroll-snap-stop: always; } .scrolling-section1 { background-color: rgb(220, 235, 153); } .scrolling-section2 { background-color: rgb(230, 173, 218); scroll-snap-align: center; } .scrolling-section3 { background-color: rgb(176, 229, 238); } </style> </head> <body> <div class="scroll-container"> <div class="scrolling-section1">scroll-snap-align</div> <div class="scrolling-section2">scroll-snap-align: center</div> <div class="scrolling-section3">scroll-snap-align</div> </div> </body> </html>
CSS Scroll Snap Align - End Value
The following example demonstrates of how to use the scroll-snap-align: end property −
<html> <head> <style> .scroll-container { display: flex; width: 350px; height: 200px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; } .scrolling-section1, .scrolling-section2, .scrolling-section3 { flex: 0 0 auto; width: 300px; height: 200px; scroll-snap-stop: always; } .scrolling-section1 { background-color: rgb(220, 235, 153); } .scrolling-section2 { background-color: rgb(230, 173, 218); } .scrolling-section3 { background-color: rgb(176, 229, 238); scroll-snap-align: end; } </style> </head> <body> <div class="scroll-container"> <div class="scrolling-section1">scroll-snap-align</div> <div class="scrolling-section2">scroll-snap-align</div> <div class="scrolling-section3">scroll-snap-align: end</div> </div> </body> </html>