【发布时间】:2017-04-17 04:46:06
【问题描述】:
我只设法使用 css 在悬停时打开它,但我不知道如何将两者结合起来并在单击时打开它,当鼠标移开时关闭它。如果之前出现过这个问题,我也很抱歉,但是我到处搜索都找不到答案。
这是我目前的代码:
<div class="col-md-3"><div class="dropdown">
<button class="btn btn-secondary dropdown-toggle text-left border-0 rounded-0 py-2" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
<i class="fa fa-plus float-right" aria-hidden="true"></i>
<i class="fa fa-minus float-right" aria-hidden="true"></i>
</button>
<div class="dropdown-menu rounded-0 border-0" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</div></div>
body {
background: #eeeeee;
}
.btn {
width: 100%;
}
.dropdown-menu {
width: 100%;
height: 100vw;
}
.dropdown:active .dropdown-menu {
display: block;
margin-top: 0;
}
.dropdown-toggle:after {
display:none;
}
.btn:active .fa-plus {
display:none
}
目前,它在点击时打开/关闭。那些字体很棒的图标之所以存在,是因为我也在努力让它们改变。
谢谢!
【问题讨论】:
标签: html css bootstrap-4