JSFiddle - React, Tailwind, and code Playground

by Ea Bangalore

HTML

<input type="checkbox" id="inp"><label for='inp'>use real opacity</label>
<div class="wrapper">
  <div class="main-display">
    <img src="https://picsum.photos/150/150?image=1069">
    <img src="https://picsum.photos/150/150?image=1024">
    <img src="https://picsum.photos/150/150?image=1011">
  </div>
  <div class="sub-display"></div>
</div>

CSS

body {
  --bg-color: #252b34;
  background: var(--bg-color);
  color: gold;
}

.wrapper {
  position: relative;
  overflow: hidden;
}

.main-display {
  height: 150px;
  position: relative;
}

.sub-display {
  position: absolute;
  left: 38%;
  top: 0;
  width: 70px;
  height: 98%;
}
.sub-display::before {
  display: block;
  width: 100%;
  height: 100%;
  content: '';
  box-shadow: 0px 0px 0px 200vmax var(--bg-color);
  border: 2px solid yellow;
  opacity: 0.7;
}

/* just to show that it works */
/* :checked ~ .wrapper .sub-display::before {
  content: none;
}
:checked ~ .wrapper .main-display {
  opacity: 0.3;
} */