列表悬停时的 CSS 箭头

标签 css

我有一个列表菜单,其边框宽度为 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/

相关文章:

HTML 转换属性

html - 如何使用CSS从输入文本框中删除文本

android - 位置 : fixed; not working when keyboard opened on kitkat

javascript - jquery : $ ("selector") or selector as an object variable? 哪个更快

css - 输入[类型 ="button"] Sprite 悬停有过渡问题

html - 左右边距不相等,这是为什么

php - 在 concrete5 中调整内容 block 的大小

javascript - 元素 offsetHeight 总是 "0"

css - 在移动设备/平板电脑上从横向更改为纵向时出现空白问题

javascript - 多 div 的动画滚动顶部问题