Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

51
Views
how do i over put something in css?

I am creating a modal and I need to place the modal above

let buttonOpen = document.querySelector(".button-open");
let buttonClose = document.querySelector(".button-close");
let modal = document.querySelector(".modal");

buttonOpen.addEventListener("click", () => {
  modal.classList.add("show-modal");
});

buttonClose.addEventListener("click", () => {
  modal.classList.remove("show-modal");
});
body {
  padding: 0;
  margin: 0;
}


/* for open the modal*/

#container {
  z-index: -1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.modal {
  display: none;
  width: 100px;
  height: 100px;
  background-color: aqua;
}

.show-modal {
  display: block;
  z-index: 1;
}
<!-- for open the modal -->
<div id="container">
  <button class="button-open">Open Modal</button>
</div>

<div class="modal">
  <div class="modal-content">
    <h3>Title a modal</h3>
    <button class="button-close">Close Modal</button>
  </div>
</div>

photo the result:

Image

and I want the box to be on top of the content so that it is not below the content but above it, as if it were a layer above my real page content

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs