Use the "sticky" style property in CSS.
- Example:
-
style="position: sticky; position: -webkit-sticky; top: 0;"
-
- Notes:
- The webkit version is required for Safari.
- A positional statement ("top" in this example) is required to let the element know what to stick to.
- This styling will not be visible while logged-in to the website, since the administrative toolbar is also "sticky" and overrides this property.
- Many other things can cause this style to fail to apply.