I make a slider. I want to do as the title says. This is necessary to control the slider only through the opacity . The main problem is that if the child elements are put position: absolute , then the parent collapses, and I need its frame.
body{ display: flex; justify-content: center; align-items: center; } .wrap { position: relative; border: 2px solid red; display: flex; justify-content: space-between; } .div{ border: 1px solid; width: 100px; height: 100px; position: absolute; } <div class="wrap"> <div class="div">1</div> <div class="div">2</div> <div class="div">3</div> <div class="div">4</div> </div>