JSFiddle - React, Tailwind, and code Playground
HTML
<div class="text"></div>
<div class="rect-border"></div>
CSS
:root {
--x: 150px;
--y: 100px;
--w: 300px;
--h: 200px;
--r: 10px;
}
body {
margin: 0;
overflow: hidden;
}
.rect-border {
position: fixed;
top: 0; left: 0;
width: var(--w);
height: var(--h);
border-style: solid;
border-color: rgba(0, 0, 0, 0.5);
border-top-width: var(--y);
border-right-width: calc(100vw - var(--x) - var(--w));
border-bottom-width: calc(100vh - var(--y) - var(--h));
border-left-width: var(--x);
}
JavaScript
const textElem = document.querySelectorAll('.text')
textElem.forEach(item => {
item.textContent = '测试文字'.repeat(800)
})