<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    <link href="https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap"
      rel="stylesheet"
    />
  </head>
  <body>
     <div class="resizable">
        <div class="pagination">
          <a href="/" class="pagination__btn">
            <span class="btn__label">Prev</span>
            <span class="btn__icon">
              <svg
                viewBox="0 0 24 24"
                stroke-width="1.5"
                stroke="currentColor"
                class="w-6 h-6"
                fill="none"
              >
                <path
                  stroke-linecap="round"
                  stroke-linejoin="round"
                  d="M15.75 19.5L8.25 12l7.5-7.5"
                />
              </svg>
            </span>
          </a>
          <div class="pagination__pages">
            <a href="/" class="pagination__page">1</a>
            <a href="/" class="pagination__page">2</a>
            <a href="/" class="pagination__page">3</a>
            <span class="pagination__page">...</span>
            <a href="/" class="pagination__page">12</a>
          </div>
          <a href="/" class="pagination__btn">
            <span class="btn__label">Next</span>
            <span class="btn__icon">
              <svg
                fill="none"
                viewBox="0 0 24 24"
                stroke-width="1.5"
                stroke="currentColor"
                class="w-6 h-6"
              >
                <path
                  stroke-linecap="round"
                  stroke-linejoin="round"
                  d="M8.25 4.5l7.5 7.5-7.5 7.5"
                />
              </svg>
            </span>
          </a>
        </div>
      </div>
  </body>
</html>
.resizable {
  resize: horizontal;
  overflow: scroll;
  width: 350px;
  font-family: Lato;
  container: pagination / inline-size;
  --button-width: 36px;
}

/** Base style */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  &__btn {
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    border-radius: 5px;
    width: var(--button-width);
    height: var(--button-width);
    cursor: pointer;
    text-decoration: none;
    color: #a2a2a2;
    display: flex;
    justify-content: center;
    align-items: center;
    &:hover {
      background-color: #4f86f4;
      color: white;
    }
  }
  &__pages {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
  }

  &__page {
    color: #a2a2a2;
    background-color: transparent;
    padding: 6px;
    border-radius: 5px;
    text-decoration: none;

    &[href] {
      cursor: pointer;
      border: none;
    }
    &:hover,
    .active {
      background-color: #4f86f4;
      color: white;
    }
  }

  .btn {
    &__label {
      display: none;
      padding: 6px;
    }
    &__icon {
      width: calc(var(--button-width) / 1.5);
      height: calc(var(--button-width) / 1.5);
    }
  }
}

/** Container queries */

@container pagination (max-width: 312px) {
  .pagination {
    .pagination__pages {
      display: none;
    }
    .btn__label {
      display: block;
    }
    .btn__icon {
      display: none;
    }
  }
}

@container pagination (max-width: 100px) {
  .pagination {
    .btn__label {
      display: none;
    }
    .btn__icon {
      display: block;
    }
  }
}
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.