gpt4 book ai didi

html - li/navigation 元素下的小边框

转载 作者:太空宇宙 更新时间:2023-11-03 19:40:48 25 4
gpt4 key购买 nike

这就是我想要实现的,但它无法弄清楚:

enter image description here

ul {
list-style-type: none;
}
li {
height: 50px;
width: 180px;
line-height: 50px;
background: #ddd;
display: inline-block;
text-align: center;
}
li:hover {
box-shadow: 0 5px 0 0 gold;
}
<ul>
<li>Hello</li>
<li>World</li>
</ul>

我只是想像上面的图片那样得到它。

最佳答案

我会为那条小线使用一个 after 元素

ul {
list-style-type: none;
}

li {
display: inline-block;
padding: 0.75em 1.5em; /* I would use padding instead of fixed width and height */
text-transform: uppercase; /* make text uppercase */
position: relative;
}

li:hover {
color: green; /* change this to your green color */
}

li:hover:after {
content:'';
display:block;
position:absolute; /* position this at the bottom */
bottom:0;
left:35%; /* left and right determine length of line, the longer you want it, the closer to 0 these values should be */
right:35%;
height:2px;
background:green; /* match the font color */
}
<ul>
<li>Hello</li>
<li>World</li>
</ul>

关于html - li/navigation 元素下的小边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44159024/

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