"Unable to get the 'sticky' position to function correctly in tailwindcss

I've been experimenting with Tailwind CSS and trying to implement two sticky elements - a sticky header and a sticky sidebar. My sticky header seems to be working perfectly:

<body>
    <header class="sticky z-50 top-0 hidden">
        <div class="grid grid-cols-12 p-1 sm:py-3 md:px-16 md:py-12 xl:px-32 xl:pt-24 bg-gray-100">
            <div class="col-span-12 mb-2 lg:col-span-3 ">
                <span id="btnMenu" onclick="toggleButton(); return false">
                    <i class="fal fa-2x fa-bars hover:bg-white"></i>
                </span>
                <span class="mx-2 float-left lg:float-none lg:mx-6">Logo</span>
            </div>
            <div class="col-span-12 lg:col-span-9">
                <span class="w-full h-10 bg-gray-200 cursor-pointer border border-gray-300 text-sm rounded-full flex">
                    <input type="search" name="serch" placeholder="Search..."
                        class="flex-grow px-4 rounded-l-full rounded-r-full text-sm focus:outline-none"> <i
                        class="fas fa-search m-3 mr-5 text-lg text-gray-700 w-4 h-4"> </i> </span>

            </div>
        </div>
    </header>

However, when I try to implement the second sticky element (as shown in the code snippet above), namely the sticky sidebar, it doesn't seem to work properly even when the header is hidden. Additionally, removing the

overflow-y-scroll  lg:overflow-y-hidden
classes doesn't resolve the issue.

<div class="relative h-auto w-auto">
    <div class="grid grid-cols-12">
        <div id="backgroundmenu"
            class="hidden z-30 absolute top-0 right-0 h-full w-full bg-black opacity-25  top-0 lg:hidden"></div>

        <div id="rightSidebar"
            class="hidden z-30 absolute right-0 top-0 h-full w-full lg:static lg:block lg:right-auto lg:top-auto col-span-12 sm:col-span-12  md:col-span-4 lg:col-span-3 xl:col-span-2">
                ...
            </div>

        <div class="sticky top-0 bg-gray-100 font-light h-full w-1/3 lg:w-auto overflow-y-scroll  lg:overflow-y-hidden">
            ...
        </div>
    </div>

I'm still troubleshooting why the sticky sidebar isn't functioning as expected. For reference, you can view the live page at: https://codepen.io/djary/pen/QWjYOGX

The "register" and "login" items should remain in a container with a sticky position.

Answer №1

It seems like the issue with your rightSidebar component is the inclusion of the h-full class, causing it to inherit the height of its parent and preventing it from becoming sticky. Try removing that class to resolve the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Struggling to properly center my login form and give it an attractive, sleek card design

Looking to create a login form similar to the one shown in this image using Bootstrap5, but struggling to do so. Is there anyone who can assist me in creating a login form like the one mentioned here? I am new to Bootstrap and CSS. Here is my current temp ...

Navigating through multiple overlapping scenes in Three.js using Orbit Controls

Seeking assistance with a dilemma involving the use of Orbit Controls with Multiple Overlapping Scenes. To showcase the issue, I made adjustments to the example found at multiple scenes and developed a test specific to my needs. The code can be accessed h ...

Regular expression that removes attributes from all HTML tags except <a>

$text = preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i",'<$1$2>', $text); Greetings. I came across a preg_replace function that identifies all HTML tags and removes their attributes. However, I need to make an exception for t ...

Switching the image by clicking on the link

Looking for assistance with a code that displays three button images and fades in the relevant div when clicked using jQuery... http://jsfiddle.net/ttj9J/11/ HTML <a class="link" href="#" data-rel="content1"><img src="http://i.imgur.com/u1SbuRE ...

Text directly in the middle

Explanation In an attempt to replicate the "middle centered text" feature, such as "Responsive Front-end Development," on this website, I am currently exploring various methods. As a newcomer to web development, I have searched for templates to provide me ...

Enhancing TYPO3 menu with custom HTML styling using stdWrap.override

Recently, I created a menu using TypoScript where I decided to customize the standard title with my own text: lib.menu = HMENU lib.menu.special = list lib.menu.special.value = 3304, 7753 lib.menu { 1 = TMENU 1 { wrap = <ul class="menu" ...

Creating a stylish layout with Bootstrap 4: equal height divs filled with color and a sleek gutter in between

I am struggling to create a bootstrap 4 layout as per my design screenshot. I have researched other Stack Overflow posts without finding a solution. The .container-fluid layout has a grey fill color, achieved using my custom class .bg-grey. As per the d ...

JQuery Mobile's Panel widget is the culprit behind the demise of the

I'm having some trouble adding a panel to my jQuery mobile page. Every time I try to input the code, all I see is a white screen with the loading widget, and nothing else happens. I have JQuery 2.0.0 hosted by Google, JQuery Mobile JS 1.3.1 hosted by ...

Information backed by the HTML5 Local Storage feature

Is it possible to use a Local Storage object to store another Local Storage object? Thank you in advance. ...

The combination of Tailwindcss and Nextjs is functioning perfectly except for components

It's really puzzling me. So, I've got this Navbar component that I'm importing into specific pages, and it's giving me some trouble. To keep things simple, for now, the Navbar component is just a styled div with a Link inside: /compone ...

Creating responsive data tables in HTML

My e-shop features a product description block using the code snippet below. While it looks great on larger screens, such as a 17" desktop monitor, it appears poorly on smaller smartphone screens. Friends have suggested that I learn Bootstrap/Flexbox and ...

Is it possible to set a single variable value for multiple attributes simultaneously in Javascript?

I would like to specify the horizontal padding of a styled element as variable 'x' and the vertical padding as variable 'y'. Here's one way to achieve this: var docex = document.getElementById.style; docex.paddingTop = y; docex.pa ...

Unable to access individual checkbox with Selenium in Java

I am looking to select the Store Pickup Available checkbox on the following page: http://www.target.com/c/pants-shorts-baby-toddler-boys-clothing/-/N-59yk1#navigation=true&viewType=medium&sortBy=newest&isleaf=true&navigationPath=59yk1& ...

Nested table border collapse is not functioning as intended

Upon inspection, it appears that border-collapse is not functioning as expected: UPDATE: In this case, when referring to border-collapse not working, I am highlighting the issue where the inner table displays a double border, resulting in an unappealing a ...

Integrating Python with MySQL and HTML

My project involves reading data from a GSM modem and storing it in a MySQL database using a Python script. Now, I want to create a front end for this process using an HTML file with a specific design in mind. The Python script acts as the backend in t ...

Utilizing Django's For Loop to Transfer Dropdown Selections to a Modal

I have a dropdown menu with different choices. When a user selects an option, I want a modal to appear with a message specific to the choice made (e.g. "You selected Choice A"). I attempted to use data-target="#myModal{{choice}}" and id="my ...

Tips on how to ensure the navigation menu is the same size as its child elements in the navigation menu

I'm currently designing a navigation menu that includes a child navigation menu. My goal is to have the size of the main navigation menu match that of the child navigation menu. To achieve this, I've created three hyperlink tags followed by a di ...

Issue with Tailwind CSS shadow and transition failing to work after activating JIT mode

After enabling tailwind JIT mode in my project, I encountered an issue where the transition stopped working and the shadow disappeared. Despite closely following instructions from a Youtube tutorial, I have yet to find a solution. Any suggestions would be ...

Google Chrome has trouble displaying the body element at 100% height

Having an issue with Google Chrome – the body element is not reaching 100% height. In my website samples, at 100% zoom when hovering over a menu element (such as "O nás"), I change the background color of the body element. However, in Chrome, the botto ...

Display a color box popup when a radio button is selected

I need help implementing a functionality where a popup modal opens when a specific radio button is checked. I have tried using colorbox with an anchor, but it doesn't seem to work with radio buttons. Does anyone have any sample code or suggestions? T ...