1

I am using the spectrum.js flat colorpicker in a page that has a position:fixed header. The picker choices overlap the header while scrolling the page.

I have found this issue, but it seems to me that it applies to a picker contained into a fixed container, and not the other way round.

Thank you for your help.

Emanuele Cipolla
  • 301
  • 3
  • 16

1 Answers1

1

With the F12 tools, I see that the color picker container has the sp-container class. In spectrum.css, the style defined for that class shows the following z-index property:

.sp-container {
    ...
    z-index: 9999994;
}

If you set z-index: 9999995 (or more) for the fixed header, the color picker box will not overlap it.

$("#inputColor").spectrum({
    color: "#f00"
});
#divHeader
{
    position: fixed;
    top: 0px;
    left: 0px;
    width: 100%;
    color: #CCC;
    background: #333;
    padding: 8px;
    z-index: 9999995;
}

#divContainer
{
    margin-top: 40px;
    width: 300px;
    height: 1200px;
    background-color: #E0E0E0;
    border: solid 1px black;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.min.js"></script>
<div id="divHeader">Fixed header</div>
<div id="divContainer">
    <input id="inputColor" type="text" />
</div>
ConnorsFan
  • 70,558
  • 13
  • 122
  • 146