How to make div background sit on top?

bring div to front without z-index
div on top of another div without absolute positioning
put one div on top of another
css z-index
div on top of div
z-index not working
div on top of everything
css position

I'm making a modal form. This is what happens when I open my modal:

As you can see logo image, search, meniu and cart is on top of my modal transparent background. Here is my HTML code:

<div id="offerModal" class="modal">
  <div class="modal-content">
    <div class="modal-header">
      <span class="closeBtn" onclick="closeModal()">&times;</span>
      <h2 class="modal-header-top">OFFER YOUR PRICE</h2>
      <hr class="hr">
    </div>
    <div class="modal-body">
      <form>

      </form>
    </div>
  </div>
</div>

And CSS code:

.modal{ 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    display: none;
    background: rgba(0,0,0,0.5);
}


.modal-content{
    border-style: solid;
    border-width: 10px;
    border-color: rgba(0,0,0,0.7);
    background-color: #f4f4f4;
    margin: 10% auto;
    padding: 10px;
    width: 30%;
    box-shadow: 0 5px 8px 0 rgba(0,0,0,0.2), 0 7px 20px 0 rgba(0,0,0,0.17);
    border-radius: 6px;
}

So how to fix this problem?

As mentioned by others, you will want to do:

.modal { 
    z-index: 99999; 
}

If this fails, then it may be worth decreasing the z-index on the logo, search bar and cart area classes to 1.

CSS I want a div to be on top of everything, Yes, in order for z-index to work, you'll need to give the element a left: 230px; width: 200px; height: 200px; top: 31px; background-color: indianred; Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0;  The following HTML-CSS code placing one image on top of another by create a relative div that is placed in the flow of the page. Then place the background image first as relative so that the div knows how big it should be. Next is to place the overlay image as absolutes relative to the upper left of the first image.

Try going:

.modal{ 
    position: fixed; 
    z-index: 99999; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    display: none;
    background: rgba(0,0,0,0.5);
}

If there is third party CSS z-index may be set somewhere else but it's hard to say with what's provided.

Stacking without the z-index property, When the z-index property is not specified on any element, elements are stacked in the following order (from bottom to top):. The background  Another toue to take would be to create div's using an image as the background, and then place content where ever you like. You've got the right idea. Looks to me like you just need to change .tag's position:relative to position:absolute, and add position:relative to .container.

W3 School Try this code

position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
outline: 0;
display:black;

How to Stack Elements in CSS, In this case, we're absolutely positioning the child to the top-left of the If we put position: relative; on the parent element, anything inside of it  Yes, in order for z-index to work, you'll need to give the element a position:absolute or a position:relative property. But pay attention to parents! You have to go up the nodes of the elements to check if at the level of the common parent the first descendants have a defined z-index.

z-index, If an element B sits on top of element A, a child element of element A can never be higher than element B. Note that older version of IE get this  By using a div with style z-index:1; and position: absolute; you can overlay your div on any other div. z-index determines the order in which divs 'stack'. A div with a higher z-index will appear in front of a div with a lower z-index. Note that this property only works with positioned elements.

How to Overlay One DIV Over Another DIV using CSS, You can use the CSS position property in combination with the z-index property to overlay an <div class="box stack-top" style="background: blue;"></div> Hey guys, I’m very new to CSS, so please excuse if my question is a bit elementary. I’m busy with laying out a fictitious website, just for learning layout and positioning. What I want to do

4 reasons your z-index isn't working (and how to fix it), Z-index is a CSS property that allows you to position HTML elements in layers on In this layout, we ideally want the white block of text to be on top of both cats. Duis commodo tincidunt ipsum, sit amet egestas dolor bibendum vel. a modal window with a transparent gray background overlay opens up. This can make the text inside a fully transparent element hard to read. Transparency using RGBA If you do not want to apply opacity to child elements, like in our example above, use RGBA color values.

Comments
  • and the css for the header ? maybe the z-index is bigger
  • probably, it's a problem of z-index. What is the link for test?
  • Try just doing z-index:99999; on that modal, that should do it.
  • without the rules for those elements, we're just going to be guessing at what is causing the z-index shift.
  • Thank you! header area z-index was set to 10. I've changed it into 1 and everything works fine now :)