I am having a repeatable tile generator. So I am generating HTML with a for loop. I need each tile, when I hover on it, to fade out and another div will be placed instead in the same location. I tried with having for each repeatable tile a div with position: relative
.. then I place a hidden div that I make it appear on hover, with position: absolute
.. however children divs are placed in the same location for the first tile, they're not placed according to their parent.
Here's the code I have that mimics what am having:
.titleContainer:hover{
opacity: 0;
}
.headers{
opacity: 0;
}
.headers:hover{
opacity: 1;
}
<div data-reactroot="" class="">
<div class="tile" style="position: relative;">
<div class="titleContainer" style="position: relative; float: left; width: 25%; margin-right: 30px;">
<img src="https://cdn.pixabay.com/photo/2018/08/31/19/16/fan-3645379_960_720.jpg" style="width: 100%; height: 200px;">
<div class="" style="background-color: red; opacity: 0.8; position: absolute; top: 0px; width: 100%; height: 40px;">
<h3 style="color: white; text-align: center; line-height: 0.5;">Random Tile</h3>
</div>
</div>
<div class="headers" style="background-color: red; position: absolute; width: 25%; height: 200px;">Hello</div>
</div>
<div class="tile" style="position: relative;">
<div class="titleContainer" style="position: relative; float: left; width: 25%; margin-right: 30px;">
<img src="https://cdn.pixabay.com/photo/2014/05/02/21/47/workstation-336369_960_720.jpg" style="width: 100%; height: 200px;">
<div class="" style="background-color: red; opacity: 0.8; position: absolute; top: 0px; width: 100%; height: 40px;">
<h3 style="color: white; text-align: center; line-height: 0.5;">Quick Links</h3>
</div>
</div>
<div class="headers" style="background-color: red; position: absolute; width: 25%; height: 200px;">Hello</div>
</div>
<div class="tile" style="position: relative;">
<div class="titleContainer" style="position: relative; float: left; width: 25%; margin-right: 30px;">
<img src="https://cdn.pixabay.com/photo/2015/01/14/18/41/home-office-599475_960_720.jpg" style="width: 100%; height: 200px;">
<div class="" style="background-color: red; opacity: 0.8; position: absolute; top: 0px; width: 100%; height: 40px;">
<h3 style="color: white; text-align: center; line-height: 0.5;">Global Links</h3>
</div>
</div>
<div class="headers" style="background-color: red; position: absolute; width: 25%; height: 200px;">Hello</div>
</div>
</div>
As you see, hovering on the first tile will only show ALL inner divs placed on top of each other, and the other tiles won't have the behavior when hovering.