gpt4 book ai didi

列表悬停时的 CSS 箭头

转载 作者:行者123 更新时间:2023-12-02 14:54:31 26 4
gpt4 key购买 nike

我有一个列表菜单,其边框宽度为 1px ...100%。

参见图 1:

enter image description here

现在是最困难的部分。当鼠标悬停在菜单项上时,我需要在悬停的元素下发生这种情况:

参见图 2:

enter image description here

我该怎么做?我一直在谷歌上搜索,但没有发现任何内容。

最佳答案

使用相对定位的列表项与旋转的绝对定位相结合,为您提供了一个可能的解决方案:

* {
margin: 0;
padding: 0;
list-style: none;
}

ul li {
display: inline-block;
vertical-align: top;
padding: 1em 3em;
margin-right: -4px;
border-bottom: 1px solid black;
position: relative;
}
ul li:hover:after {
content: ' ';
display: block;
height: 16px;
width: 16px;
background: white;
position: absolute;
left: 50%;
margin-left: -8px;
transform: rotate(45deg);
bottom:-9px;
border-left: 1px solid black;
border-top: 1px solid black;
}
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
</ul>

关于列表悬停时的 CSS 箭头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33168537/

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