html - Bootstrap - 第二列顶部填充?

标签 html css twitter-bootstrap

我有一个包含两列的页面。一切都很好而且 react 灵敏,但是,我注意到当我调整到移动 View 时,第二列堆叠在下面(太棒了!)但是内容就在第一列内容的正下方所以看起来很糟糕。

有没有办法创建这种间距?尝试使用类和 ID 定位并使用边距和填充,但似乎没有什么不同。

<div class="container">
    <div class="row">
        <div class="col-sm-5">
            <h1>Title</h1>
            <p>Little bit of content</p>
        </div>
        <div class="col-sm-6 col-sm-offset-1">
            <h1>Title</h1>
            <p>Little bit of content</p>
        </div>
     </div>
</div>

最佳答案

Is there a way to create this spacing?

是的。这可以通过使用 @media 查询将某些样式应用于特定断点上的第 2、3、... 列来实现。例如:

/* Extra small devices (phones, less than 768px) */
@media (max-width: 767px) {
    [class*="col-"] + [class*="col-"] {
        padding-top: 1em; /* for instance */
    }
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
    <div class="row">
        <div class="col-sm-5">
            <h1>Title</h1>
            <p>Little bit of content</p>
        </div>
        <div class="col-sm-6 col-sm-offset-1">
            <h1>Title</h1>
            <p>Little bit of content</p>
        </div>
     </div>
</div>

关于html - Bootstrap - 第二列顶部填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28616734/

相关文章:

html - 是否可以为超过两个具有不同高度的元素的 HTML 元素实现正确的 Material 设计阴影?

html - 分组 CSS 类与具有相同属性时的单个类 性能 - SASS/SCSS 实现

javascript - 为什么我的事件监听器不在函数内工作?

html - 当其他div中的内容宽度大于100%时,div不显示100%宽度

html - 如何将图像放在顶部但仍能响应?

jquery - 用于最佳移动和桌面体验的 UI 控制

jquery - 特定尺寸和位置的实心球

javascript - 选项卡中的 Bootstrap 链接不起作用

html - 如何从 Bootstrap 列中删除填充和边距?

iphone - 在 iPhone 上无法选择的超链接和按钮 - 适用于所有其他浏览器