JSFiddle - React, Tailwind, and code Playground
by hcarleton
HTML
<div class="parent">
<div class="box"></div>
</div>
<div class="tall"></div>
CSS
body { margin: 0; }
html {
box-sizing: border-box;
}
*, *::before, *::after {
box-sizing: inherit;
position: relative;
}
.parent {
position: static; /* .box will get it's percentage width form the body element */
background: rgba(0, 0, 0, .4);
height: 100px;
width: 5rem;
margin-bottom: 25px;
}
.box {
position: absolute;
top: 0;
left: 0;
height: 50px;
width: 100%; /* 100% of body width */
background: rgba(0, 0, 0, .4);
border: 2px solid red;
}
.tall {
height: 100rem;
}