In a wrapper div, there are two inner divs with different text. The goal is to change the text on hover and position the second text div exactly where the first text div is.
.wrapper {
background: red;
width: max-content;
padding: 20px;
}
.text1 {
background: green;
opacity: 1;
transition: all 0.5s;
}
.text2 {
background: yellow;
opacity: 0;
transition: all 0.5s;
}
.wrapper:hover>.text1 {
opacity: 0;
}
.wrapper:hover>.text2 {
opacity: 1;
}
<div class="wrapper">
<div class="text1">Text 1</div>
<div class="text2">Text 2</div>
</div>
Is it possible to overlap two text-divs within one wrapper div?
This Stackoverflow post discusses an overlapping issue, but my situation requires adjusting the wrapper dimensions to match the text size.