0

Twitter Bootstrap 导航组件中的下拉菜单在下拉菜单顶部有一个“提示”。

在此处输入图像描述

如何在正常的下拉菜单中添加提示?

在此处输入图像描述

<div class="dropdown">
    <a href="#" data-toggle="dropdown">
        Click me
    </a>
    <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
        <li><a tabindex="-1" href="#">Action</a></li>
    </ul>
</div>
4

2 回答 2

3

添加这个CSS:

.dropdown-menu:before {
  position: absolute;
  top: -5px;
  left: 9px;
  display: inline-block;
  border-right: 7px solid transparent;
  border-bottom: 7px solid #ccc;
  border-left: 7px solid transparent;
  border-bottom-color: rgba(0, 0, 0, 0.2);
  content: '';
}

.dropdown-menu:after {
  position: absolute;
  top: -3px;
  left: 10px;
  display: inline-block;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #ffffff;
  border-left: 6px solid transparent;
  content: '';
}

我从nav下拉样式中得到它并更改了几个值。它应该很容易根据您的需要进行调整。

于 2013-06-14T11:18:37.830 回答
1

这是 Bootstrap 4 的更新解决方案。只需应用以下 CSS 并向dropdown-menu-tip-[n|ne|nw|s|se|sw]菜单添加修饰符。

[class*="dropdown-menu-tip-"]::after {
  content: '';
  position: absolute;
  width: .5rem;
  height: .5rem;
  background-color: white; /* For SCSS use $dropdown-bg */
  border: solid 1px rgba(0, 0, 0, .15); /* For SCSS use $dropdown-bg */
  border-bottom: none;
  border-left: none;
}

/* North */
.dropdown-menu-tip-n::after {
  top: calc(-.25rem - 1px);
  left: calc(50% - .25rem);
  transform: rotate(-45deg);
}

/* Northeast */
.dropdown-menu-tip-ne::after {
  top: calc(-.25rem - 1px);
  right: 1rem;
  transform: rotate(-45deg);
}

/* Northwest */
.dropdown-menu-tip-nw::after {
  top: calc(-.25rem - 1px);
  left: 1rem;
  transform: rotate(-45deg);
}

/* South */
.dropdown-menu-tip-s::after {
  left: calc(50% - .25rem);
  bottom: calc(-.25rem - 1px);
  transform: rotate(135deg);
}

/* Southeast */
.dropdown-menu-tip-se::after {
  right: 1rem;
  bottom: calc(-.25rem - 1px);
  transform: rotate(135deg);
}

/* Southwest */
.dropdown-menu-tip-sw::after {
  left: 1rem;
  bottom: calc(-.25rem - 1px);
  transform: rotate(135deg);
}

演示:https ://codepen.io/claviska/pen/LzvMpx

来源:https ://www.abeautifulsite.net/adding-a-checked-state-to-bootstrap-4-dropdown-menus

于 2017-10-23T13:30:38.587 回答