如何在NAV BAR中悬停链接
我敢肯定,其他人可能会遇到同样的问题,但我不仅是CSS的新手,英语也不是我的主要语言,因此我真的不知道该如何研究如何解决这个问题。我不知道该怎么称呼这种情况。基本上,在悬停的情况下,文本稍微移动而不是留在其所属的位置。我假设我在桨上做错了什么。但是我知道,可以具有这种“按钮”效果,例如,悬停效果的背景颜色具有该大小,但我真的无法找到解决方案...我已经花了几个小时尝试不同的方法但没有成功。我也不确定我是否适当地设计了链接。有人可以帮忙吗?
这是下面的Navbar CSS代码:
.nav-items {
display: flex;
transform: translateX(0px);
margin-right: 5%;
}
.nav-items li {
list-style: none;
padding: 25px;
}
.nav-items a {
color: white;
text-decoration: none;
letter-spacing: 1px;
font-size: 14px;
}
.nav-items li a:hover {
background-color:#006aff;
padding: 20px;
transition: 0.2s ease-in-out;
}
I am sure others might have experienced the same problem, but not only am I new to CSS, English is also not my main language, and therefore I don't really know how to go about researching on how to solve this issue. I don't know what to call this situation. Basically, upon hover, the text slightly moves instead of staying where it belongs. I am assuming I am doing something wrong with paddings. But I know that it is possible to have this "button" effect, as in, the background color of the hover effect having that size, but I really can't figure out a solution... I have been hours and hours trying different methods but no success. I am also not sure if I am styling the links properly. Can someone help please?
Here's my navbar CSS code below:
.nav-items {
display: flex;
transform: translateX(0px);
margin-right: 5%;
}
.nav-items li {
list-style: none;
padding: 25px;
}
.nav-items a {
color: white;
text-decoration: none;
letter-spacing: 1px;
font-size: 14px;
}
.nav-items li a:hover {
background-color:#006aff;
padding: 20px;
transition: 0.2s ease-in-out;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如我所见,您正在悬停在悬停状态下添加填充物。
您的代码应该像这样描述的方式,要显示导航项目。
As I can see you are adding the padding in the hover state.
Your code should be like this the way you have described you want to show the navigation items.