I’m trying to make a navigation bar with UL LI elements, I want to use a tooltip when the mouse is over the LI element using hover. But it doesn’t seem to work, I tried to look through other examples, only that I have several containers and I think that’s the problem if you can help me.
So here is the html code in which I have a side-menu placed on the left inside, I have a side-bar-left menu and a side-bar-right menu on the left there will be an icon and on the right the channels. And I want to make the user touch with the mouse, hover the LI element to display a tooltip of example messages.
<nav class="side-menu">
<div class="side-bar-left">
<ul class="logo">
<li>
<a href="#">
<img class="logo-image" src="/images/logo.png" alt="" />
</a>
<span class="tooltiptext">Messages</span>
</li>
</ul>
<div class="side-bar-right">
</div>
</nav>
And here are the styles, they almost work, only when the hover tooltiptext appears, it occupies the entire surface at LI, but that’s not what I need, I want it to be placed outside at li and on the right side
.logo li {
position: relative;
/* Adăugați această proprietate pentru a face elementul <li> relativ pozitionat */
}
.logo li .tooltiptext {
visibility: hidden;
width: 120px;
background-color: black;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
top: -40px;
/* Plasați tooltip-ul deasupra elementului <li> */
left: 50%;
/* Plasați tooltip-ul în centrul elementului <li> */
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.3s, visibility 0s 0.3s;
/* Am adăugat o întârziere pentru a face tooltip-ul să dispară mai încet */
}
.logo li:hover .tooltiptext {
visibility: visible;
opacity: 1;
transition-delay: 0s;
/* Anulăm întârzierea pentru a face tooltip-ul să apară imediat la hover */
}
here is an example of how it should be
enter image description here
2
Answers
this is how it looks the first li is not straight enter image description here
You need to fix the style as
JsFiddle
Edit: I put the entire html content