<div class="box">
  <div class="box-inner">
    <div class="box-main">
      <div class="elements-holder">
        <div class="elements-flexbox">
          <div class="element element-static"></div>
          <div class="element element-dynamic">
            <div class="elem-1"></div>
            <div class="elem-2"></div>
          </div>
          <div class="element element-static"></div>
        </div>
        <code>transform: translate(<span data-digit-id="translate-px_x">0px</span>, <span data-digit-id="translate-px_y">0px</span>);</code>
      </div>
    </div>
    <div class="controller">
      <div class="controller-item">
        <div class="indicator">
          <label for="translate-px_x">x:</label>
          <span class="digit" data-digit-id="translate-px_x">0px</span>
        </div>
        <div class="slider">
          <input type="range" id="translate-px_x" min="-50" max="50" value="0" oninput="showVal(this.value, 'translate-px_x')" onchange="showVal(this.value, 'translate-px_x')">
        </div>
      </div>
      <div class="controller-item">
        <div class="indicator">
          <label for="translate-px_y">y:</label>
          <span class="digit" data-digit-id="translate-px_y">0px</span>
        </div>
        <div class="slider">
          <input type="range" id="translate-px_y" min="-50" max="50" value="0" oninput="showVal(this.value, 'translate-px_y')" onchange="showVal(this.value, 'translate-px_y')">
        </div>
      </div>
    </div>
  </div>
</div>
@import url('https://fonts.googleapis.com/css2?family=League+Spartan&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@500&display=swap');

:root {
  --font-family-mono: 'League Mono', monospace;
  --font-family-dm: 'DM Sans', sans-serif;
  --translate-px_x: 0px;
  --translate-px_y: 0px;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
.box {
  background: #151f28;
  max-width: 750px;
  margin: 20px auto;
  border-radius: 8px;
  padding: 16px 32px;
  font-size: 16px;
}
.box-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.box-main {
  padding: 50px 32px 32px;
  background: white;
  border-radius: 4px;
  min-height: 200px;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.elements-holder {
  min-width: 475px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 50px;
}
.elements-flexbox {
  display: flex;
  gap: 16px;
}
.element {
  width: 80px;
  height: 80px;
}
.element-static {
  background: #9295a0;
}
.element-dynamic {
  position: relative;
}
.elem-1 {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
  border: 4px dashed #9295a0;
}
.elem-2 {
  position: relative;
  width: 100%;
  height: 100%;
  background: #4433ff;
  opacity: 0.8;
  transform: translate(var(--translate-px_x), var(--translate-px_y))
}
code {
  font-size: 1rem;
  font-family: var(--font-family-mono);
  background: #e1e3ea;
  padding: 6px 8px;
  border-radius: 4px;
}
.controller {
  display: grid;
  gap: 32px;
  grid-template-columns: 1fr 1fr;
  color: white;
  font-family: var(--font-family-dm);
  font-weight: 500;
}
.indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.digit {
  font-size: 0.875em;
}
.slider {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 1.625rem;
}
.slider input {
  background: transparent;
  appearance: none;
}
.slider input::-webkit-slider-runnable-track {
  height: 4px;
  background-color: #5c6670;
}
.slider input::-webkit-slider-thumb {
  appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50px;
  background: #d9e0e8;
  cursor: grab;
  transform: translateY(-6px);
}
function showVal(val, id){
  let _px = `${val}px`;
  $(`[data-digit-id=${id}]`).text(_px);
  $(':root').css(`--${id}`, _px);
};

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.3/jquery.min.js