Imagine a hidden side menu that expands upon interaction:
.collapsedSideMenu {
height: 100%;
width: 40px;
background-color: grey;
color: white;
font-size: 12px;
margin: 0px;
padding: 0px;
}
.menuItem {
display: flex;
justify-content: center;
padding: 8px;
position: relative;
}
.menuItem:hover {
background-color: blue;
color: grey;
}
.menuTitle {
position: absolute;
display: flex;
justify-content: center;
padding: 8px;
background-color: blue;
color: grey;
}
<div class="collapsedSideMenu">
<div class="menuItem">AB</div>
<div class="menuTitle">Option AB</div>
<div class="menuItem">CD</div>
<div class="menuTitle">Option CD</div>
<div class="menuItem">EF</div>
<div class="menuTitle">Option EF</div>
</div>
The task is to display the title (menuTitle
) when hovering over its respective option (menuItem
), appearing next to the collapsed choice.
For example:
| AB |
| CD | Option AB | << On hover over CD
| EF |
How can this be achieved using CSS/HTML?