gpt4 book ai didi

html - 向后导航动画

转载 作者:行者123 更新时间:2023-12-04 17:13:15 24 4
gpt4 key购买 nike

如果在 nav li a::after 上设置 100% 宽度,为什么在导航栏上显示动画,那条红线向后工作,而不是从左到右,它应该如何或我想要如何?
HTML

        <nav>
<ul>
<li><a href="index.php">Domů</a></li>
<li><a href="switcher.php">Fun Switcher</a></li>
<li><a href="#">Radio</a></li>
<li><a href="#">Fotky</a></li>
<li><a href="#">Games</a></li>
<li><a href="#">Chat</a></li>
</ul>
</nav>

CSS
nav {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
background: linear-gradient(#ffffff, #f5f5f5);
grid-area: nav;
font-weight: bold;
}

nav ul {
list-style: none;
margin: 0;
display: flex;
justify-content:flex-start;
align-items: center;
padding: 1em 0;
}

nav li a {
text-decoration: none;
color: #000000;
padding-left: 3em;
position: relative;
transition: all ease-in-out 250ms;
}

nav li a::after {
content:'';
position: absolute;
display: block;
height: 0.4em;
background-color: red;
bottom: -1em;
/* width: 100%; look for whole line */
transition: all ease-in-out 250ms;
}

nav li a:hover::after {
width: 60%;
}

nav li a:hover{
color: red;
}

最佳答案

您想更改多项内容,因为某些 css 属性不适合您的 html 类...

nav {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
background: linear-gradient(#ffffff, #f5f5f5);
grid-area: nav;
font-weight: bold;
}

nav ul {
list-style: none;
margin: 0;
display: block;
}

nav li {
padding: 13px 20px;
display: inline-block;
}

nav li a {
text-decoration: none;
color: #000000;
position: relative;
transition: all ease-in-out 250ms;
}

nav li a::after {
content:'';
position: absolute;
display: block;
height: 0.4em;
background-color: red;
bottom: -1em;
/* width: 100%; look for whole line */
transition: all ease-in-out 350ms;
left: 0;
width:0;
}

nav li a:hover::after {
width: 100%;
}

nav li a:hover{
color: red;
}
 <nav>
<ul>
<li><a href="index.php">Domů</a></li>
<li><a href="switcher.php">Fun Switcher</a></li>
<li><a href="#">Radio</a></li>
<li><a href="#">Fotky</a></li>
<li><a href="#">Games</a></li>
<li><a href="#">Chat</a></li>
</ul>
</nav>

关于html - 向后导航动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69097465/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com