<div class="container">
  <h1>vertical-align: <span id="valPer">100</span><i id="per">%</i></h1>
  <h1>vertical-align: <span id="valPix">76.8</span><i id="pix">px</i></h1>
</div>

<div class="actions">
  <label for="percentage">vertical-align:</label>
  <input type="range" id="percentage" name="percentage" min="-300" max="300" value="100" step="5">
  <span>%</span>
</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%;
  line-height: 150%;
  letter-spacing: 0.1rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-blend-mode: hue;
}

.container {
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: relative;
  margin-top: auto;
  font-size: 2rem;
}

.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;
}

:root {
  --vertical-align: 100%;
}

h1 {
  display: inline-block;
  background: linear-gradient(to right, #44ea76 0%, #39fad7 80%, #39fad7 100%)
      no-repeat,
    url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/142996/slider-2.jpg")
      no-repeat fixed;
  background-size: cover;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

h1 {
  border: 1px dotted #0ff;
  padding: 20px 50px;
  border-radius: 5px;
  position: relative;
  line-height: 120%;
  margin: 10px;
  white-space: nowrap;
}

h1:last-child {
  border-color: #ff9800;
}

h1 i {
  -webkit-text-fill-color: #fff;
  background-color: #f36;
}

h1:last-child i {
  -webkit-text-fill-color: #ff9800;
  background-color: #efe;
}

#per {
  vertical-align: var(--vertical-align);
}

#pix {
  vertical-align: 76.8px;
}

.container::before {
  content: "<i>元素的line-height计算出来的值为76.8px";
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.85);
  padding: 3vh;
}
const rangeElement = document.getElementById("percentage");
const perVal = document.getElementById("valPer");
const pixVal = document.getElementById("valPix");
const pix = document.getElementById("pix");

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

  perVal.textContent = etv.target.value;

  pixVal.textContent = (etv.target.value * 76.8) / 100;

  pix.style.verticalAlign = (etv.target.value * 76.8) / 100 + "px";
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.