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 609 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 a Reply to Sridhar Katakam (Cancel Reply)

 

Related Tutorials..

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 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:
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:
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:
Width and Height of Mobile Hamburger Toggle in Bricks

Width and Height of Mobile Hamburger Toggle in Bricks

Looking to change the size of Bricks hamburger toggle in the mobile menu? The default width value of 20px can be changed by selecting the…
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:
Pro
Custom Posts Grid Layout in Bricks using CSS Grid

Custom Posts Grid Layout in Bricks using CSS Grid

There are at least three ways in which we can build custom loops in Bricks. Posts elementTurning on Query Loop on a containerCode element While…
Categories:
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:
Floats in Bricks for Wrapping Text Around Images

Floats in Bricks for Wrapping Text Around Images

In the Bricks Facebook group a user asks: Float, left or right? Just a quick question. Am I going crazy or can't I specify a…
Categories:
Tags: