css - 使用 bootstrap 创建 10 列的网格

标签 css twitter-bootstrap

是否可以使用 bootstrap 创建 10 列布局? col-md-1 给出 12,col-md-2 给出 6,但我需要 10。我该如何实现?是否有任何 css “hacks”?

我正在考虑将 2 个 5 列网格彼此相邻粘贴(来自 this 问题/答案),但我不确定如何处理。

最佳答案

Bootstrap 3: 如果你想要全宽,你可以使用 this aproach .

但是您必须使用:10% 而不是 20% (1/5 *100%):

.col-xs-1-10,
.col-sm-1-10 {
  position: relative;
  min-height: 1px;
}

.col-xs-1-10 {
  width: 10%;
  float: left;
}

@media (min-width: 768px) {
  .col-sm-1-10 {
    width: 10%;
    float: left;
  }
}

@media (min-width: 992px) {
  .col-md-1-10 {
    width: 10%;
    float: left;
  }
}

@media (min-width: 1200px) {
  .col-lg-1-10 {
    width: 10%;
    float: left;
  }
}
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
  <div class="col-xs-1-10">
    1
  </div>
  <div class="col-xs-1-10">
    2
  </div>
  <div class="col-xs-1-10">
    3
  </div>
  <div class="col-xs-1-10">
    4
  </div>
  <div class="col-xs-1-10">
    5
  </div>
   <div class="col-xs-1-10">
    6
  </div>
    <div class="col-xs-1-10">
    7
  </div>
  <div class="col-xs-1-10">
    8
  </div>
  <div class="col-xs-1-10">
    9
  </div>
  <div class="col-xs-1-10">
    10
  </div>
</div>

Bootstrap 4: 使用 this aproach .

关于css - 使用 bootstrap 创建 10 列的网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44671734/

相关文章:

CSS - 删除输入字段事件突出显示

html - 1 个像素会导致 Bootstrap 列溢出,还有如何使我的列大小动态化?

HTML CSS : Make Parent Flex equal Width of Children Automatically

html - 叠加层未正确调整 CSS 大小

html - 如何在 Bootstrap 中将导航栏品牌居中

CSS :lang pseudo class vs attribute selector

css - 如何从 GitHub 以不同的权重显示 Noto Sans?

javascript - 缩放图像和图像变化

css - 为移动、屏幕和打印提供不同样式表的简单方法

html - 在其中自定义 bootstrap 5 按钮颜色和属性