Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

position: sticky not working in firefox

position:sticky is said to be working in firefox but I'm not seeing my sidebar stick.

My html looks like this:

<div class="wrap">

    <div class="sticky">side </div>    
    <div class="content">content <div>
<div>

My css:

.content{
    height: 2000px;
    overflow: hidden;
}

.sticky{
    position: sticky;
    width: 200px;
    float: left;
}

As I scroll down the sidebar scrolls with the content. It doesn't stick. Anyone know what could be the issue?

like image 288
Elfy Avatar asked Dec 17 '14 08:12

Elfy


People also ask

Why is my sticky position not working?

Sticky Element Has Parent(s) with overflow PropertyIf the sticky element has a parent or ancestor with overflow: hidden , overflow: auto , or overflow: scroll , then position: sticky will not work properly.

Does Firefox support position sticky?

This is the demo from MDN. CSS position: sticky is supported in Firefox, Safari, and Chrome Canary (56+).

Is position sticky supported?

Position Sticky is supported by all major modern browsers, except for old IE. For Safari browsers you will need to add the -webkit prefix.


2 Answers

I have the same issue in 2020 - this post pops up first in google but none of the answers helped me.

The actual problem was that sticky doesn't play well with the parent element being display: flex.

References:
- position: sticky, works in Chrome but not in Firefox
- https://bugzilla.mozilla.org/show_bug.cgi?id=1488080

like image 72
de. Avatar answered Sep 28 '22 19:09

de.


It sticks if you specify a top value:

.sticky{
   position: -webkit-sticky; /* for safari */
   position: sticky;
   width: 200px;
   float: left;
   top: 10px;
}

fiddle

like image 25
nice ass Avatar answered Sep 28 '22 17:09

nice ass