Having trouble adding a sidebar to my grid system
I'd really love help here if someone can dissect and figure out my dilemma.
I have this WordPress site which is built using Advanced Custom Fields' flexible content fields. It's not using Gutenberg/the block builder.
The user can add a section (
<section>
). They have some basic options, like class and background colour
β³ Inside each section they can nest what we're calling blocks, several if desired. Think text block (<div>
), image block (<figure>
), infobox (<div>
), etc.). The blocks have some basic options, like class, background colour, and importantly width - narrow, standard, or wide.
I set up a CSS grid to automatically give the children a width, whether the chosen narrow, standard, or wide. Standard is default. See here:
π¨π¨π¨
So, my actual issue here is that I want to also incorporate a sticky sidebar on some pages. How on earth can I do that? It feels like I need an entirely new grid system but I'm dizzy running myself in circles now. The sections span the full width of the page, and they need to continue to so that I get the full-width background colours per section, while the content should take up the left 3/4 of the content-container.. but then how am I do actually make a sticky sidebar stay atop those on the rightmost 1/4? So that it can scroll down along the page? Is this explanation even making sense? π₯²
π¨π¨π¨
Pen here: https://codepen.io/emsixteen/pen/dyrmZJN4 Replies
Example markup:
Example sass:
A sticky sidebar or a fixed sidebar ? Can you give the page a padding of 25% or whatever the width of that sidebar is? Or do you want the content to go underneath/be hidden by the sidebar ?
And what element in your pen is the sidebar in question ?
Sticky sidebar! The sections need to be under the sidebar, rather than beside, else the background wouldn't go fullwidth
The sidebar isn't in the pen, that's just the example grid set-up
I'm free to add the sidebar markup anywhere in that markup, other than between sections π
I think that's kinda where my biggest problem is - That the background colours for each section need to stretch full-width of the page, so I don't think it can just be like,
Iβm not seeing a class called sticky-sidebar in your markupβ¦
So itβs hard to say without seeing the element in question and the styles
Do you want the sidebar to stick on the top or on the left of the page? And do you want it to always be there or should it scroll away with one of the sections at some point ?