Currently, I am working on developing a collapsible sidebar menu for my project. The objective is to have the text displayed when hovering over it and hidden when not in use. While I have found solutions for changing properties of other elements upon hover, I am struggling to apply these changes to both the text itself and another property simultaneously.
The basic HTML structure is outlined below:
.sidebar {
position: fixed;
top: 0;
left: 0;
background-color: #1d326b;
height: 100%;
width: 60px;
transition: 0.3s;
border-radius: 0 5px 5px 0;
font-family: 'Open Sans', sans-serif;
overflow: hidden;
}
.sidebar:hover > .text {
display: block; /*The text should be displayed*/
width: 150px; /*Expands the sidebar*/
}
<div class="sidebar">
<!--more containers...-->
<!--deeply nested text container-->
<p class="text">Displayed Text</p>
</div>
I am seeking a CSS-based solution to tackle this issue. Any insights or suggestions would be greatly appreciated!