这是 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