<div class="container">
  <div class="element"></div>
</div>

<div class="actions">
  <label for="width">width:</label>
  <input type="range" id="width" name="width" min="10" max="100" value="50" step="5">
  <span id="width-per">50%</span>
  (<strong id="width-pix">250px</strong>)

  <label for="height">height:</label>
  <input type="range" id="height" name="height" min="10" max="100" value="50" step="5">
  <span id="height-per">50%</span>
  (<strong id="height-pix">100px</strong>)
</div>
@import url("https://fonts.googleapis.com/css?family=Gochi+Hand");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 100vw;
  min-height: 100vh;
  margin: 0;
  background-color: #291642;
  font-family: "Gochi Hand", sans-serif;
  font-size: 100%;
  letter-spacing: 0.1rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-blend-mode: hue;
}

.container {
  width: 500px;
  height: 200px;
  display: flex;
  position: relative;
  margin-top: auto;
  box-shadow: 0 0 2px 0 #f36;
}

.container::before {
  content: "width: 500px";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translate(-50%, 0);
}

.container::after {
  content: "height: 200px";
  position: absolute;
  left: 100%;
  top: 50%;
  white-space: nowrap;
  transform: translate(-40%, -50%) rotate(90deg);
}

.actions {
  padding: 3vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.5);
  width: 100%;
  font-size: 2rem;
  margin-top: auto;
}

label:nth-of-type(2) {
  margin-left: 20px;
}

:root {
  --width: 50%;
  --height: 50%;
}

.element {
  width: var(--width);
  height: var(--height);
  background-color: #09f;
}

strong {
  color: #f89;
}
const rangeWidth = document.getElementById("width");
const rangeHeight = document.getElementById("height");

const widthPerVal = document.getElementById("width-per");
const widthPixVal = document.getElementById("width-pix");

const heightPerVal = document.getElementById("height-per");
const heightPixVal = document.getElementById("height-pix");

const containerElement = document.querySelector(".container");

rangeHeight.addEventListener("change", (etv) => {
  document.documentElement.style.setProperty(
    "--height",
    `${etv.target.value}%`
  );

  const heightRangeValue = etv.target.value;
  const heightPixValue =
    (heightRangeValue * containerElement.getBoundingClientRect().height) / 100;

  heightPerVal.textContent = `${heightRangeValue}%`;
  heightPixVal.textContent = `${heightPixValue}px`;
});

rangeWidth.addEventListener("change", (etv) => {
  document.documentElement.style.setProperty("--width", `${etv.target.value}%`);

  const widthRangeValue = etv.target.value;
  const widthPixValue =
    (widthRangeValue * containerElement.getBoundingClientRect().width) / 100;

  widthPerVal.textContent = `${widthRangeValue}%`;
  widthPixVal.textContent = `${widthPixValue}px`;
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.