css - Bootstrap div对齐问题

标签 css twitter-bootstrap-3 sidebar col

我在尝试在 Bootstrap 3 中对齐我的 div 时遇到问题。

这是我想要完成的: enter image description here

我使用过拉和推,但我想我还不够好。

代码:

<div class="container">
    <div class="row">
        <div class="col-md-9 col-md-push-3 blue">
            blue
        </div>
        <div class="col-md-3 col-md-pull-9 red">
            red
        </div>
        <div class="col-md-9 col-md-push-3 orange">
            orange
        </div>
        <div class="col-md-3 col-md-pull-9 green">
            green
        </div>
        <div class="col-md-3 col-md-pull-9 purple">
            purple
        </div>             
    </div>
</div>

http://jsfiddle.net/bva5z74w/1/

最佳答案

我在看这个是想看看是否有人会回答这个显而易见的问题:不要为此使用引导推拉。使用 float 权利,没有 float 。在最小宽度处,蓝色必须比红色高,除此之外我认为这会很顺利。

enter image description here

演示:http://jsbin.com/degeju/1/

CSS:

.blue {
    background: blue
}
.red {
    background: red
}
.orange {
    background: orange
}
.green {
    background: green
}
.purple {
    background: purple
}
.red,
.blue,
.green,
.orange,
.purple {
    height: 50px
}

@media (min-width:992px) { 
    .blue {
        height: 600px;
        float: right;
    }
    .red {
        height: 300px;
        float: none;
    }
    .orange {
        height: 400px;
        float: right;
    }
    .green {
        height: 200px;
        float: none;
    }
    .purple {
        height: 200px;
        float: none;
    }
}

HTML

<div class="container">
    <div class="row">
        <div class="col-md-9 blue">
            blue
        </div>
        <div class="col-md-3 red">
            red
        </div>
        <div class="col-md-9 orange">
            orange
        </div>
        <div class="col-md-3 green">
            green
        </div>
        <div class="col-md-3 purple">
            purple
        </div>             
    </div>
</div>  

关于css - Bootstrap div对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26596950/

相关文章:

javascript - 刷新 AJAX 内容时保持 jquery 动画

javascript - 为什么 CSS 中的这个 SVG 片段标识符在操作 onclick 时不会呈现?

html - 如何在导航栏(菜单)元素上应用或更改颜色

r - 使用 bslib 的可折叠侧边栏无需额外的 JS?

javascript - Leaflet Sidebar V2 设置默认打开

SwiftUI 侧边栏不记得状态

css - Bootstrap 4 - 左对齐一个大复选框

javascript - 我的 circle-divs 不工作。为什么?

javascript - 单选按钮未选择选项

css - 显示自定义复选框的 HTML5 验证消息