Search code examples
javascriptcsswordpresssticky

Sticky position on Wordpress site


I'm trying to make a sticky element in my website that it's made in wordpress with a custom template.

I was trying everything, from css (position: sticky) should work. But in my case is not.

Can you help me with this issue? This is the structure of the page, on the left the sticky element that I want. On the right, the content

Thank you you very much for your time.


Solution

  • I have checked your code.Position sticky is not working as because one of the parent div has overflow:hidden property so basically position sticky is not working with overflow hidden so please apply below property in your css file and then check

    <style>
        aside.widget-area.col-xs-12.col-sm-12.col-md-4.col-lg-3.order-2-sm-sidebar {
            position: sticky;
            top: 80px;
            height: 600px;
            overflow-y: scroll;
        }
    
        #widthContent {
            overflow: unset !important;
        }
    
    </style>