![]() |
VOOZH | about |
Foundation CSS is a free and open-source front-end framework for developing flexible web designs. It's one of the most powerful CSS frameworks, and it delivers a responsive grid, as well as HTML and CSS UI components, templates, and more, across all platforms. It also has several JavaScript extension features that are optional. It also renders quickly on mobile devices thanks to the inclusion of the Fastclick.js utility.
The sticky component is used to create anything that stays at the top of the page when the user scrolls down it. Sidebars, external links, and topbars can all be created with these components. To make a sticky element, use the sticky class and the data-sticky property with an element. The data-sticky-container parameter governs the sizing and the grid layout of sticky items.
With the already stated attributes and class, we can make an element sticky but it will stay sticky throughout the document. But if we want to specify a certain space through which the element will stay sticky and scrollable, we can use two anchors to specify from where the element will start being sticky and where it will stop being sticky.
To specify the anchors we can use two attributes data-top-anchor="idOfSomething:[top/bottom]", data-btm-anchor="idOfSomething:top/bottom]" or we can even set a pixel number instead of an id data-top-anchor="pixelNumber".
Foundation CSS Sticky Advanced classes:
Foundation CSS Sticky Advanced Attributes:
Example 1: The below example demonstrates how we can specify the position where the image will start being sticky and stop being sticky.
Output:
Example 2: The below example demonstrates how we can specify the position where the navigation bar will start being sticky and stop being sticky.
Output:
Reference: https://get.foundation/sites/docs/sticky.html#advanced