html - 在工具提示中显示的 div 顶部添加一个三 Angular 形?

标签 html css

<分区>

我有一个 div,它将在悬停某个元素时显示。当我们将鼠标悬停在元素上时将显示的 div 显示在元素下方。我需要使用 css 将三 Angular 形 /\ 添加到 div 的顶部。

我怎样才能做到这一点?

HTML

<div class="user-options">
        <ul class="settings">
            <li><a href="home.html">JOHN DOE</a></li>
            <li><a href="user-customization.html">My Playground</a></li>
            <li><a href="myrules.html">Settings</a></li>
            <li><a href="index.html">Logout</a></li>
        </ul>
    </div>

CSS

.user > .user-options {
    background: none repeat scroll 0 0 #eeeeee;
    display: none;
    margin-top: 25px;
    overflow: auto;
    padding: 0 0 0 10px;
    position: absolute;
    width: 125px;
    z-index: 999;
    border:solid #cccccc 1px;
    margin-left:-24px;
}

最佳答案

你可以这样做:

注意:从 .user-options

中删除 overflow: auto;

CSS

.user-options {
    background: none repeat scroll 0 0 #eeeeee;
    margin-top: 25px;
    padding: 0 0 0 10px;
    position: absolute;
    width: 125px;
    z-index: 999;
    border:solid #cccccc 1px;
    margin-left:-24px;
}

.user-options:after, .user-options:before {
    bottom: 100%;
    left: 50%;
    border: solid transparent;
    content: " ";
    height: 0;
    width: 0;
    position: absolute;
    pointer-events: none;
}

.user-options:after {
    border-color: rgba(238, 238, 238, 0);
    border-bottom-color: #eeeeee;
    border-width: 15px;
    margin-left: -15px;
}
.user-options:before {
    border-color: rgba(204, 204, 204, 0);
    border-bottom-color: #cccccc;
    border-width: 16px;
    margin-left: -16px;
}

DEMO HERE

关于html - 在工具提示中显示的 div 顶部添加一个三 Angular 形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30048133/

相关文章:

html - 用 css 覆盖内联样式

css - 堆叠 Canvas 移除默认透明度 HTML

html - 将分隔线和 iframe 拉伸(stretch)到屏幕高度

javascript - php连续调用多个html页面

python - PyQuery Python 不支持 for 循环

javascript - 自动填充 HTML 字段 - 使用 NodeJs 和 mySQL

html - 调整下拉菜单大小以匹配链接宽度

javascript - 将响应式 div 高度设置为等于其同级

css - 这两种修复折叠父级和 float 子级的方法是相同的,但是为什么呢?

javascript - 当列标题卡在页面顶部时如何对齐它们