0

I'm trying to create an popup, but I have problems with z-index and positions.

.filterBar is as follows :

.filterBar{
    position: fixed;
    z-index: 3;
    left: 275px;
    right: 15px;
    display: flex;
    align-items: center;
    height: 40px;
    background-color: #f9f9f9;
}

outter (it takes the whole body) is as follows :

#outter{
    z-index: 99999999;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0px;
    left: 0px;
    bottom: 0px;
    right: 0px;
    width: 100%;
    height: 100%;
    background: rgba(22, 23, 23, 0.8);
}

With this styling I get next :

enter image description here

Thus, the filter bar is in front of outter div, no matters that outter has bigger z-index.

If I remove z-index: 3 from .filterBar class, then everything works nice.

enter image description here

But I can't remove z-index because I need it for the styling of the rest of the page.

Boky
  • 11,554
  • 28
  • 93
  • 163

1 Answers1

0

That's happening because of display: flex elements. When you use flex items, they are displayed as inline-block elements.

[> 4.3. Flex Item Z-Ordering

Flex items paint exactly the same as inline blocks [CSS21], except that order-modified document order is used in place of raw document order, and z-index values other than auto create a stacking context even if position is static.][1]

You'll need to apply display: flex to body

Jordi Flores
  • 2,080
  • 10
  • 16