JSFiddle - React, Tailwind, and code Playground

HTML

<div class="box">
  <div class="text"></div>
  <div class="rect-outline"></div>
</div>

CSS

:root {
  --x: 150px;
  --y: 100px;
  --w: 300px;
  --h: 200px;
  --r: 10px;
}

.box {
  position: relative;
  width: 600px;
  height: 400px;
  margin-bottom: 10px;
  overflow: hidden;
  background: #fff;
}

.rect-outline {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  outline: 3000px solid rgba(0, 0, 0, 0.5);
}

JavaScript

const textElem = document.querySelectorAll('.text')

textElem.forEach(item => {
  item.textContent = '测试文字'.repeat(176)
})