html - 移动版 col-xs-6 中连续两个框不起作用

标签 html css twitter-bootstrap twitter-bootstrap-3

我正在使用 bootstrap 3。在桌面版中我有四个连续的盒子。但是我想在移动版中连续放置两个盒子,所以我使用了 col-xs-6 但这东西不起作用。我是 bootstrap 的新手,你们能帮帮我吗。

这是我的手机版enter image description here

我要这样,手机版两个一排装enter image description here

我的 HTML

<div class="container">
<div class="row">
<div class="col-sm-12" id="middleBoxMargin">
<div id="middleBox">
<div id="groupInsurance" class="col-xs-6 group-insurance"></div>
<div id="lifeInsurance" class="col-xs-6 life-insurance"></div>
<div id="dentalInsurance" class="col-xs-6 dental-insurance"></div>
<div id="replacementInsurance" class="col-xs-6 replacement-insurance"></div>
</div>
</div>
</div>
</div>

我的 CSS

#middleBoxMargin {
    margin-top: 80px;
}

#middleBox {
    display: flex;
    justify-content: center;
}

#groupInsurance {
    float: left;
    width: 145px;
    height: 125px;
    background-color: #EEEEEE;
    text-align: center;
    cursor: pointer;
}

#lifeInsurance {
    float: left;
    width: 145px;
    height: 125px;
    background-color: #EEEEEE;
    text-align: center;
    margin-left: 15px;
    cursor: pointer;
}

#dentalInsurance {
    float: left;
    width: 145px;
    height: 125px;
    background-color: #EEEEEE;
    text-align: center;
    margin-left: 15px;
    cursor: pointer;
}

#replacementInsurance {
    float: left;
    width: 145px;
    height: 125px;
    background-color: #EEEEEE;
    text-align: center;
    margin-left: 15px;
    cursor: pointer;
}

最佳答案

如果您打算使用 Bootstrap 网格,只需删除为您的容器添加的所有特定宽度:-

用于桌面使用 col-md-4

用于移动屏幕 col-xs-6 <div id="groupInsurance" class="col-md-4 col-xs-6"></div>

关于html - 移动版 col-xs-6 中连续两个框不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50086396/

相关文章:

css - 第一次点击移动设备时会打开带有悬停叠加层的链接

html - 图像叠加在响应大小的图像 Bootstrap 上

javascript - 我可以在 FullCalendar 中设置 eventClickLimit 弹出窗口的样式吗

javascript - 页脚总是固定在页面 Bootstrap 的底部?

javascript - 如何动态地创建/输入一个项目作为无序列表中另一个项目的子列表项目?

javascript - 单击 HTML 加载元素?

python - 通过 Python Flask 从一个 HTML 输入中获取多个值

html - Bootstrap 模态元素不工作

javascript - 带有 jQ​​ueryUI 排序的 Twitter Bootstrap 多级 Accordion

javascript - 如何在 Vanilla JS 中从位置过渡到动画?