There is wrapper div contains two div with different text. I need to change the text on hover and the gol is to place text2 div at the same position as text1.
.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>
How do I overlap 2 text-divs in one wrapper div?
This is not exactly the same question, in the link author sets width: 100%; height: 100%; but I have to adjust the wrapper height and width to text size somehow.