为什么我的工具提示没有显示在链接悬停时?
几天来我一直在尝试让我的工具提示显示出来,但没有任何进展。当不透明度为 1 时,如果您想查看它们应该是什么样子,它们可以通过块选择器 .sidebar ul li .tooltip {} 显示在侧边栏中。
我尝试将 z-index 添加到 .sidebar ul li a:hover .tooltip {} 选择器以及 opacity:1,但这不起作用。
我还尝试更改“hover”以应用于“li”而不是“a”标签,但这不会改变任何内容。并尝试将其添加到两者 (.sidebar ul li:hover a:hover .tooltip {}) 但也不起作用。
这是不透明度的问题还是选择器的问题?我感觉我已经尝试了一切。
当我在浏览器开发工具中选择工具提示元素并强制进入悬停状态时,您可以看到工具提示位于正确的位置,但位于所有内容后面或不可见。
任何帮助将不胜感激,谢谢。
.sidebar ul li a:hover {
background-color: #ae85f1;
}
.sidebar ul li a:hover .tooltip {
transition: all 0.5s ease;
top: 50%;
opacity: 1;
display: block;
z-index:500;
}
.sidebar ul li .tooltip {
position: absolute;
color: #343434;
left: 130px;
top: 0;
transform: translate(-50%, -50%);
border-radius: 6px;
height: 35px;
width: 122px;
background: #fff;
line-height: 35px;
text-align: center;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
transition: 0s;
pointer-events: none;
opacity: 1;
}
.sidebar.active ul li .tooltip {
display: none;
}
I have been trying for a few days to get my tooltips to show up without any progress. They can appear in the sidebar with this block selector .sidebar ul li .tooltip {} when opacity is 1, if you want to see what they should look like.
I tried adding z-index to the .sidebar ul li a:hover .tooltip {} selector, along with opacity:1, but that doesn't work.
I also tried changing the 'hover' to apply to the 'li' instead of the 'a' tag but that doesn't change anything. and also tried adding it to both (.sidebar ul li:hover a:hover .tooltip {}) but doesn't work either.
Is this a problem with opacities, or with selectors? I feel like I've tried everything.
When I select the tooltip element in the browser dev tools and force into hover state, you can see the tooltip is there in the right spot, but just behind everything or invisible.
Any help would be appreciated thank you.
.sidebar ul li a:hover {
background-color: #ae85f1;
}
.sidebar ul li a:hover .tooltip {
transition: all 0.5s ease;
top: 50%;
opacity: 1;
display: block;
z-index:500;
}
.sidebar ul li .tooltip {
position: absolute;
color: #343434;
left: 130px;
top: 0;
transform: translate(-50%, -50%);
border-radius: 6px;
height: 35px;
width: 122px;
background: #fff;
line-height: 35px;
text-align: center;
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
transition: 0s;
pointer-events: none;
opacity: 1;
}
.sidebar.active ul li .tooltip {
display: none;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CSS 中存在一些问题,您需要更新代码中的以下更改。
更改 1:
从第 32 行
ul
CSS 中删除overflow: hide;
更改 2:
添加
display: none;
onsidebar ul li a .tooltip
CSS on line No: 123Change 3:
Add
!important
onsidebar.active ul li .tooltip
CSS on line No: 141所有更改也更新在下面的代码片段中,我希望它能帮助您。谢谢
There are few issues in CSS, You need to update below changes in your code.
Change 1:
Remove
overflow: hidden;
fromul
CSS on line No: 32Change 2:
Add
display: none;
onsidebar ul li a .tooltip
CSS on line No: 123Change 3:
Add
!important
onsidebar.active ul li .tooltip
CSS on line No: 141All changes also updated on below code snippet, I hope it'll help you out. Thank You