<div class="overflow" id="box">
  <div class="element">
    <h2>Expanding Clipping Bounds<small><code>overflow:clip</code> and <code>overflow-clip-margin</code></small></h2>
    <p>What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
    <p dir="rtl">الكلمة الافتتاحية للمدير العام لمنظمة الصحة العالمية في جلسة الاستماع العامالمتعلقة بوضع صك دولي جديد بشأن التأهب والاستجابة للجائحة - 12 نيسان/ نيسان/أبريل 2022. ولكن حتى ونحن نعمل على القضاء على هذه الجائحة، فإننا ندين لأولئك الذين لقوا حتفهم بسببها وأولئك الذين تضرروا منها بتعلم الدروس المؤلمة التي تقدمها لنا وإدخال التغييرات التي يجب أن نجريها للتأكد من أن العالم متأهب على نحو أفضل للجائحة التالية.</p>
  </div>
</div>

<form>

  <input id="overflow-clip-margin" type="checkbox" />
  <label for="overflow-clip-margin">overflow-clip-margin:</label>
  <input type="range" min="0" max="10" value="0" step="2" name="clip-margin" id="clip-margin" disabled>
  <output id="output-clip-margin">0</output>

</form>
@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: grid;
  grid-template-rows: 1fr auto;
  gap: 1rem;
}

.overflow {
  inline-size: min(360px, 100%);
  max-block-size: 240px;
  border: 1px solid #f9f9f9;
  border-radius: 4px;
  box-shadow: 0 0 1px rgb(0 0 0 / 0.4);
  padding: 5px;
  margin: 2rem auto;
  scroll-behavior: smooth;
}

.element {
  width: 135%;
  padding: 2em;
  aspect-ratio: 16 / 9;
  background: linear-gradient(rgba(255, 255, 255, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.6) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.6) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.6) 1px, transparent 1px),
    linear-gradient(
      135deg,
      rgba(84, 232, 220, 1) 0%,
      rgba(241, 231, 103, 1) 25%,
      rgba(240, 229, 104, 1) 50%,
      rgba(254, 182, 69, 1) 75%,
      rgba(250, 118, 47, 1) 100%
    );
  background-size: 20px 20px, 20px 20px, 20px 20px, 20px 20px, 100% 100%;
  background-blend-mode: hard-light, overlay, screen, saturation;
  color: #000;
  letter-spacing: 0.0125em;
  hyphens: auto;
  text-shadow: 1px 1px 0 rgb(255 255 255 / 50%);
  font-size: 1.25em;
}

.element > * {
  margin-block-end: 2rem;
  line-height: 1.6;
}

code {
  display: inline-flex;
  padding: 0.25em 0.5em;
  font-weight: bold;
  background-color: #3f51b5;
  color: #fff;
  border-radius: 5px;
  font-size: 1em;
}

h2 small {
  font-size: 62.5%;
}

.overflow {
  --clip-margin: 0;
  overflow: clip;
  overflow-clip-margin: var(--clip-margin);
}

form {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 2rem;
  background: rgb(16 18 27 / 40%);
  backdrop-filter: blur(20px);
  font-family: "Exo", Arial, sans-serif;
}

label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 0.25em;
  position: relative;
  line-height: 1;
  color: #cbcbcb;
  font-family: "Exo", Arial, sans-serif;
}

input[type="checkbox"] {
  height: 1px;
  overflow: hidden;
  width: 1px;
  position: absolute;
  clip-path: inset(50%);
}

label::before {
  content: "";
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  border: 1px solid #cbcbcb;
  background: #fff;
  color: #cbcbcb;
  width: 24px;
  aspect-ratio: 1;
  transition: all 0.2s ease;
}

input[type="checkbox"]:checked + label {
  color: #0075ff;
}

input[type="checkbox"]:checked + label::before {
  content: "✔";
  border-color: #0075ff;
  background-color: #0075ff;
  color: #fff;
  font-size: 0.75em;
}

input[type="range"]:disabled {
  cursor: not-allowed;
  pointer-events: none;
}

input[type="range"]:disabled + output {
  color: #cbcbcb;
}

let overflowBox = document.getElementById("box");
const clipCheckbox = document.getElementById("overflow-clip-margin");
const clipRange = document.getElementById("clip-margin");
const outputBox = document.getElementById("output-clip-margin");

clipCheckbox.addEventListener("change", (etv) => {
  clipCheckbox.checked
    ? clipRange.removeAttribute("disabled")
    : clipRange.setAttribute("disabled", true);
});

clipRange.addEventListener("change", (etv) => {
  overflowBox.style.setProperty(`--clip-margin`, `${etv.target.value}rem`);
  outputBox.textContent = `${etv.target.value}rem`;
});
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.