如何制作A:悬停是Flexbox中这些父容器的块颜色?
现在,我学会了使用Flex创建一个Navbar,这是我的Codepen: codepen
我想要悬停在li中的锚标签,它将在li中为背景颜色提供整个高度, 与Sass一样,这样:
ul {
list-style-type: none;
width: 33%;
display: flex;
align-items: center;
justify-content: space-between;
min-height: 4rem;
li {
a {
text-decoration: none;
color: $color-0;
}
a:hover {
background-color: $color-8;
}
}
}
For now, I learn to create a navbar with flex, This is my codepen : Codepen
I want anchor tag in li when hovering, it will give background color entire height in li,
With sass, like this :
ul {
list-style-type: none;
width: 33%;
display: flex;
align-items: center;
justify-content: space-between;
min-height: 4rem;
li {
a {
text-decoration: none;
color: $color-0;
}
a:hover {
background-color: $color-8;
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您的 ul 选择器中尝试此造型,
还将UL选择器的填充编辑为
填充:0 0 0 2REM;
> ,因此NAV-Links如图所示,被卡住了极端Try this piece of styling in your ul selector
Also edit the padding of ul selector to
padding: 0 0 0 2rem;
so the nav-links get stucked to extreme right as shown in the image