Shopify Size chart popup not scrolling issue

Belljones
New Member
5 0 0

I have followed this tutorial- https://shopify.dev/tutorials/customize-theme-add-size-chart however the size chart that I have is large and needs to be able to scroll. How do I change the css to allow scrolling? It doesn't seem to work when I add overflow: scroll to .pop-up-modal, So it just sticks in the middle of the page and becomes unusable.

This is the code below-

 

<div class="pop-up-modal">
   <div class="pop-up-content">
      <span class="close-button">&times;</span>
      <span class="size-chart-content">{{ pages.bra-pop-up-size-chart.content }}</span>
   </div>
</div>

<script>
    const modal = document.querySelector(".pop-up-modal");
    const trigger = document.querySelector(".trigger-pop-up");
    const closeButton = document.querySelector(".close-button");

    function toggleModal() {
        modal.classList.toggle("show-pop-up");
    }

    function windowOnClick(event) {
        if (event.target === modal) {
            toggleModal();
        }
    }

    trigger.addEventListener("click", toggleModal);
    closeButton.addEventListener("click", toggleModal);
    window.addEventListener("click", windowOnClick);
</script>

<style>

.pop-up-modal {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  display: none;
  transform: scale(1.1);
  transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
}
.pop-up-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  padding: 1rem 1.5rem;
  width: auto;
  border-radius: 0.5rem;
}
.pop-up-content table {
  table-layout: auto;
}
.close-button {
  float: right;
  width: 1.5rem;
  line-height: 1.5rem;
  text-align: center;
  cursor: pointer;
  border-radius: 0.25rem;
  background-color: lightgray;
}
.close-button:hover {
  background-color: darkgray;
}
.show-pop-up {
  z-index: 12;
  opacity: 1;
  display: block;
  transform: scale(1.0);
  transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
}
.trigger-pop-up {
  margin: 10px 0 10px 0;
  width: 100%;
}
@media only screen and (max-width: 749px) {
  .pop-up-content, .size-chart-content table {
    width: 100% ;
  }
  .size-chart-content th, .size-chart-content td {
    padding: 10px;
  }
}
</style>

 Thanks!

0 Likes