微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用 bootstrap 5 或 css 在图标下创建带有文本的按钮?

如何解决如何使用 bootstrap 5 或 css 在图标下创建带有文本的按钮?

我想使用 Bootstrap 5 或我自己的 CSS 类创建以下按钮。我怎样才能做到这一点?

示例: [按钮组][1]

如您所见,其中一些用作下拉按钮。

我一直在寻找,但我只找到了在同一行中包含图标和文本的示例。也许我必须使用引导卡? [1]:https://i.stack.imgur.com/V78lr.png

解决方法

在文本和图标周围放置一个 div,然后设置 display: flex;flex-direction: column; 应该可以解决问题

,

解决方案:

.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/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/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> 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?