#scroll-snap-type
“scroll-snap-type” property is applied to the container(parent) element. It defines the scrolling axis and the type of snapping behavior.
-
scroll-snap-type: none;
no snapping behavior.
-
scroll-snap-type: x;
the scroll container snaps to snap position in its horizontal axis only.
-
scroll-snap-type: y;
the scroll container snaps to snap position in its vertical axis only.
-
scroll-snap-type: both;
the scroll container snaps to snap position in both of its axes independently (potentially snapping to different elements in each axis).
-
scroll-snap-type: mandatory;
the scrolling will always snap to the closest snap point after scroll operation.
-
scroll-snap-type: proximity;
the scrolling will snap to closest snap point if it’s within a certain distance.
#"mandatory" VS "proximity"
mandatory
the scrolling will always snap to the nearest snap point after scroll operation, regardless of how far or close the scroll position is to the snap points. In other words, it enforces a strict snapping behavior, ensuring that the scroll position align precisely with a snap point.
proximity
the scrolling will snap to the nearest snap point only if it’s within a certain distance. If the scroll position is close enough to a snap point, it will snap, otherwise, it will not.
#scroll-padding
“scroll-padding” property in CSS is used to set the padding area for a scroll container. The “scroll-padding” property allows web developer to define additional space around the content inside the scroll container. The extra space influences the calculation of the snap points.
It can take one to four values, each representing the padding for the top, right, bottom, and left sides. These value can be specified in pixel, percentages, or other length units.