title: Modal is not responsive for mobile, How to make it responsive on mobile?
body: <p>My modal floats on the center of a desktop screen but on a mobile screen it floats on the top. When I keep reducing my screen size, it keeps holding its upper side, I want to show my modal content in the center of my phone screen. How can I make it float on the center of my phone's screen? I am attaching my code below. Thank you in advance.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const modals = document.querySelectorAll(".modal");
  const modalBtns = document.querySelectorAll(".button");
  const closeBtns = document.querySelectorAll(".close");
  
  // Events
  modalBtns.forEach((btn, index) =&gt;
    btn.addEventListener("click", () =&gt; openModal(index))
  );
  closeBtns.forEach((btn, index) =&gt;
    btn.addEventListener("click", () =&gt; closeModal(index))
  );
  // for closing when you click outside
  modals.forEach((modal, index) =&gt;
    modal.addEventListener("click", (e) =&gt; {
     if(e.target === e.currentTarget){
       closeModal(index);
     }
  })
  );
  
  // Open
  function openModal(index) {
    modals[index].style.display = "block";
  }
  
  // Close
  function closeModal(index) {
    modals[index].style.display = "none";
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* Modal section styling */
  
  :root {
  --modal-duration: 1s;
  --modal-color: crimson;
  }
  
  .button {
  font-family: 'poppins', sans-serif;
  display: inline-block;
  background: crimson;
  color: #fff;
  font-size: 18px;
  font-weight: 500;
  padding: 8px 16px;
  margin-top: 20px;
  border-radius: 6px;
  border: 2px solid crimson;
  transition: all 0.3s ease;
  }
  
  .button:hover {
  color: crimson;
  background: none;
  }
  
  .modal {
  font-family: 'Poppins', sans-serif;
  display: none;
  position: fixed;
  z-index: 99999;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  }
  
  .modal-content {
  margin: 51px auto;
  width: 60%;
  box-shadow: 0 5px 8px 0 rgba(0, 0, 0, 0.2), 0 7px 20px 0 rgba(0, 0, 0, 0.17);
  animation-name: modalopen;
  animation-duration: var(--modal-duration);
  }
  
  .modal-header h2,
  .modal-footer h3 {
  margin: 0;
  }
  
  .modal-header {
  background: var(--modal-color);
  font-size: 20px;
  text-align: center;
  padding: 10px;
  color: #fff;
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  }
  
  .modal-body {
  background:crimson;
  }
  
  .modal-footer {
  background: var(--modal-color);
  padding: 10px;
  font-size: 15px;
  color: #fff;
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  }
  
  .close {
  float: right;
  font-size: 30px;
  color: #fff;
  }
  
  .close:hover,
  .close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
  }
  
  .responsive {
  width: 100%;
  height: auto;
  }
  @keyframes modalopen {
  from {
      opacity: 0;
  }
  to {
      opacity: 1;
  }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;button id="modal-btn" class="button"&gt;Modal&lt;/button&gt;
  &lt;div id="my-modal" class="modal"&gt;
      &lt;div class="modal-content"&gt;
      &lt;div class="modal-header"&gt;
          &lt;span class="close"&gt;&amp;times;&lt;/span&gt;
          &lt;h3 style="font-weight: 400"&gt;On Going Project&lt;/h3&gt;
      &lt;/div&gt;
      &lt;!-- Modal Body --&gt;
      &lt;div class="modal-body"&gt;
          &lt;img src="#" alt="" style="width:100%;height:100%;"&gt;
      &lt;/div&gt;
      &lt;div class="modal-footer"&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>