html - 在所有设备上具有全宽的并排框

标签 html css

我需要并排显示容器内每个框的相同全宽 100% 的框,并跨越所有设备尺寸。 现在下面的工作,它显示了我所追求的,但是这个解决方案不适用于平板电脑和智能手机等实际物理设备,我不知道为什么,但是是否可以更改我的代码以便效果实际显示如何设计在物理设备上(而不只是在我的浏览器中并调整浏览器大小以查看效果)?

.box2 {
  margin: 5px 5px 5px 0;
  text-align: center;
  float: left;
  background-color: #FFF;
  color: #000;
  border: 2px solid #A10000;
  height: auto;
  width: calc((100% / 2) - 5px);
  box-sizing: border-box;
  font-size: 12px;
}
.row {
  margin-right: -15px;
  margin-left: -15px;
}
.container {
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}

@media screen and (min-width: 768px) {
  .box2 {
    width: calc((100% / 3) - 5px);
  }
}
@media screen and (min-width: 992px) {
  .box2 {
    width: calc((100% / 6) - 5px);
  }
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>

<div class="container">
  <div class="row">
  <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
      <a href="#" class="box2 dfs-1-sm" title="1"><h1>1</h1></a>
      <a href="#" class="box2 dfs-2-sm" title="2"><h1>2</h1></a>
      <a href="#" class="box2 dfs-3-sm" title="3"><h1>3</h1></a>
      <a href="#" class="box2 dfs-4-sm" title="4"><h1>4</h1></a>
      <a href="#" class="box2 dfs-5-sm" title="5"><h1>5</h1></a>
      <a href="#" class="box2 dfs-6-sm" title="6"><h1>6</h1></a>
    </div>
  </div>
</div>

最佳答案

.row的子div,也就是第三个div,的显示设置为flex,像这样:

.container > .row > div {
    display: flex;
}

关于html - 在所有设备上具有全宽的并排框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40077183/

相关文章:

javascript - 使用 JavaScript 以编程方式提醒 Bing map 上的纬度/经度值

html - 填充使水平滚动条出现

CSS 定位的 Canvas 大小不同于其他 block 元素(左上角右下角属性的约束)

css - 如何在 twitter bootstrap 中居中表单?

html - 如何将 float 元素的无序列表置于页面中心

html5网络录音: is input source selection possible?

html - Bootstrap 3 : Display panels inside their wells on browser resize

javascript - 单击按钮时在 div 中打开新选项卡

javascript - UIB 模态背景不淡入

html - 如何使填充全宽而屏幕两侧没有任何空白?