Search code examples
cssbuttonbootstrap-5bootstrap-cards

How to create button with text under icon using bootstrap 5 or css?


I want to create the following buttons using Bootstrap 5 or my own CSS classes. How can I achieve that?

Examples: [Set of buttons][1]

As you can see, some of them are working as a dropdown button.

I have been looking and I only have found examples with icon and text in the same line. Perhaps I have to use a Bootstrap Card? [1]: https://i.sstatic.net/V78lr.png


Solution

  • Solution:

    .command-button {
      width: 85px; 
      display: flex; 
      flex-direction: column; 
      text-align: center; 
      background: #f8f9fa; 
      padding: 10px; 
      margin: 0px 3px;
      -ms-touch-action: manipulation;
      touch-action: manipulation;
      cursor: pointer;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      background-image: none;
      border: 1px solid transparent;
      border-radius: 4px;
      border-color: #ccc;
    }
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
    
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
    
    
    
    <div style="display: flex; flex-direction: row; padding: 0px 15px;">
      <div class="command-button dropdown">
        <img src="" width="30" height="30" style="margin: auto; margin-bottom: 5px;">
        <b class="dropdown-toggle" id="dropdownVisibilidad" data-bs-toggle="dropdown" aria-expanded="false">
          Visible
         </b>
         <ul class="dropdown-menu" aria-labelledby="dropdownVisibilidad">
            <li><a class="dropdown-item" href="#" >Hacer visible</a></li>
            <li><a class="dropdown-item" href="#" >Hacer no visible</a></li>
         </ul>
      </div>
      <div class="command-button">
        <img src="" width="30" height="30" style="margin: auto;">
        <b>Eliminar</b>
      </div>
    </div>