My current challenge is getting this element to open on click and close when the mouse moves away. I've managed to make it open on hover using CSS, but I'm struggling to combine both behaviors. Unfortunately, my searches haven't yielded a solution so far.
This is the code I have been working on:
<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:hover .dropdown-menu {
display: block;
margin-top: 0;
}
.dropdown-toggle:after {
content: '';
}
.btn:hover .fa-plus {
display:none
}
Currently, the element opens/closes on click. The fontawesome icons are included as part of an attempt to change them dynamically.
Thank you!