<div class="box"></div>

<div class="form">

  <label for="background-position">background-position:</label>
  <select name="background-position" id="background-position">
    <optgroup label="Keyword values">
      <option value="left">left</option>
      <option value="top">top</option>
      <option value="right">right</option>
      <option value="bottom">bottom</option>
      <option value="center">center</option>
    </optgroup>
    <optgroup label="<length> values">
      <option value="0">0</option>
      <option value="50px">50px</option>
      <option value="5rem">5rem</option>
      <option value="5vw">5vw</option>
      <option value="5em">5em</option>
      <option value="5ch">5ch</option>
    </optgroup>
    <optgroup label="<percentage> values">
      <option value="5%">5%</option>
      <option value="50%">50%</option>
    </optgroup>
  </select>

</div>
@import url("https://fonts.googleapis.com/css2?family=Exo:wght@600&display=swap");

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

body {
  width: 100vw;
  min-height: 100vh;
  font-family: "Exo", Arial, sans-serif;
  background-color: #557;
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  gap: 1rem;
}

.box {
  width: min(100%, 600px);
  background-color: #fff;
  aspect-ratio: 16 / 9;
  box-shadow: 0 0 10px 1px rgb(0 0 0 / 25%);
  border: 1.625em solid rgb(220 20 20 / 38%);
}

:root {
  --position: left;
}

.box {
  background: #fff
    url("//www.w3cplus.com/sites/default/files/blogs/2022/2207/avatar.svg")
    var(--position) / 100px 100px no-repeat;
  overflow: hidden;
  resize: both;
}

.form {
  padding: 1rem;
  background-color: rgb(0 0 0 / 0.6);
  backdrop-filter: blur(20px);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.form select {
  padding: 0.25em 0.5em;
  font-size: inherit;
}
const rootElement = document.documentElement;
const repeatHander = document.getElementById("background-position");

repeatHander.addEventListener("change", (etv) => {
  rootElement.style.setProperty("--position", etv.target.value);
});
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.