3rd Dec '23
/
2 comments

Sticky Element using Position Sticky

Sticky Element using Position Sticky

If you are looking to make an element, typically, the site header sticky whether it is at the top of the page to begin with or at another position down below on the page we can use the display: sticky CSS rule to make that element stick to the top of the page when it touches the top edge of the browser.

Example what we are aiming for:

Apply the following styling to the element:

Position: sticky

Top: var(--wp-admin--admin-bar--height,0)

Z-index: 2

var(--wp-admin--admin-bar--height,0) equals the WP admin bar height, if present or 0, if admin bar is not present.

You may also want to set a background color.

Get access to all 610 Bricks code tutorials with BricksLabs Pro

2 comments

  • Carsten Sachse

    Hello Sridhar,

    is it possible to get a sticky section in the center of a page like a button / menu and when you scroll down the button / menu will be sticky at the top from the page.

    Thanks Carsten

Leave your comment

 

Related Tutorials..

Pro
Sticky Posts in Bricks

Sticky Posts in Bricks

This Pro tutorial provides the steps to output sticky posts using a Posts element or a Query Loop enabled container/block in Bricks. Add a Posts…
Categories:
Tags:
How to display a Query Loop in 3 columns in Bricks

How to display a Query Loop in 3 columns in Bricks

This tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.
Categories:
How to Add a Dot Separator Between Nav Menu Items in Bricks

How to Add a Dot Separator Between Nav Menu Items in Bricks

Looking to add a circular dot separator between the nav menu items in your Bricks site? Add the following at Bricks → Settings → Custom…
Categories:
Tags:
How to Create a Right Overflow Effect on Sliders in Bricks

How to Create a Right Overflow Effect on Sliders in Bricks

In this tutorial, we'll learn how to recreate a nice overflow effect on the right of our sliders in Bricks. Introduction Recently, I've been asked…
Categories:
Auto Responsive Grids in Bricks

Auto Responsive Grids in Bricks

This tutorial provides the CSS that can be pasted for automatic responsive grids in Bricks Builder. Posts element Each post will get a right padding…
How to Change Bricks Preloader Background Color

How to Change Bricks Preloader Background Color

Working on a dark-themed site like our friend Storm and getting blinded by the light background of Bricks' preloader screen of the editor? Here's how…
Categories:
Pro
Changing Bricks Lightbox Arrow Icons

Changing Bricks Lightbox Arrow Icons

How to change the left and right arrow svg icons with custom ones in Bricks lightbox.
Categories:
Tags:
Pro
Sticky Scrolling in Bricks Builder

Sticky Scrolling in Bricks Builder

Updated on 22 Apr 2024 This Pro tutorial provides the steps to fix elements in the viewport i.e., make them sticky while adjacent content in the section…
Categories:
Tags: