html - 在 bootstrap css 中的按钮组

标签 html css twitter-bootstrap

我需要创建一个与 bootstrap css 非常相似的 btn 组类。我创建了它,但我无法填补按钮之间的空白,也无法映射按钮之间的原因。

https://jsfiddle.net/frcbn82p/

您实际上可以注意到按钮之间有一个小间隙。我怎样才能删除它。

我的CSS是

    .btn-group{
  display:inline-block;
}
.btn-group button{
  width:auto;

  height:40px;
  border:none;
  background-color:#4444ee;
  color:#fff;
}

最佳答案

display: inline-block; 元素上的 HTML white-space 问题,因此一种选择是删除 HTML 代码中的空格。或者您可以在 parent 上设置 font-size: 0,然后在 child 上再次更改它 Demo .或者您可以在 HTML 中使用注释 Demo .或者你可以只使用 display: flex; Demo

.btn-group{
  display:inline-block;
}

.btn-group button{
  width:auto;
  height:40px;
  border:none;
  background-color:#4444ee;
  color:#fff;
}
<div class="btn-group">
  <button>Hello World</button><button>Hello World</button>
</div>

关于html - 在 bootstrap css 中的按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35153926/

相关文章:

javascript - 如何在 Bootstrap 中折叠内容并更改按钮中的字形?

jquery - 每次悬停父菜单时,如何延迟子菜单? (前端)

html - 像 Word 文档一样格式化

javascript - 当动态创建表单时,如何从 Meteor Event 中的 HTML 表单获取值?

javascript - 对 div 内 2 列文章中的元素应用相同的高度

html - 使 ul nav 的 block 元素自动填充整个宽度

html - css: text-align: center 只适用于多行文本,而不是单行?

css - 理解 viewBox : how to use the correct size

css - Less guard 不处理 mixin 的多个参数

html - 移动布局不呈现宽度 : 100%