Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 5 Floating Action Button

I have the following code to represent a floating action button:

.dropup .hide-toggle.dropdown-toggle::after {
    display: none !important;
}
<div class="dropup position-absolute bottom-0 end-0 rounded-circle m-5">
    <button type="button" class="btn btn-success btn-lg dropdown-toggle hide-toggle" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">
        <i class="fa-solid fa-plus"></i>
        <span class="visually-hidden">Add Category</span>
    </button>
    <ul class="dropdown-menu">
        <li>
            <a class="dropdown-item" href="#">...</a>
        </li>
    </ul>
</div>

But I'm having an issue hiding the toggle icon in the .dropdown-toggle despite having a CSS rule to have it not display.

What can I do to remove the icon?

like image 768
David Avatar asked May 24 '26 09:05

David


2 Answers

Are you sure it's not working? I see no icon here.

.dropup .hide-toggle.dropdown-toggle::after {
  display: none !important;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

<div class="dropup position-absolute bottom-0 end-0 rounded-circle m-5">
  <button type="button" class="btn btn-success btn-lg dropdown-toggle hide-toggle" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">
    <i class="fa-solid fa-plus"></i>
    <span class="visually-hidden">Add Category</span>
  </button>
  <ul class="dropdown-menu">
    <li>
      <a class="dropdown-item" href="#">...</a>
    </li>
  </ul>
</div>
like image 101
Rok Benko Avatar answered May 25 '26 23:05

Rok Benko


To get above example working i needed to change one small part. Moving the rounded-circle from the div to the button to get the rounded circle to show.

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

<div class="dropup position-absolute bottom-0 end-0  m-5">
  <button type="button" class="btn btn-success rounded-circle btn-lg dropdown-toggle hide-toggle" data-bs-toggle="dropdown" aria-expanded="false" aria-haspopup="true">
    <i class="fa-solid fa-plus"></i>
    <span class="visually-hidden">Add Category</span>
  </button>
  <ul class="dropdown-menu">
    <li>
      <a class="dropdown-item" href="#">...</a>
    </li>
  </ul>
</div>
like image 35
Niels Avatar answered May 25 '26 23:05

Niels



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!