html - 如何解决 Bootstrap 中的嵌套列

标签 html css twitter-bootstrap

我正在尝试使用 Bootstrap 构建页面结构,但遇到了几个问题。

我有一个左容器,其中包含一些列,而右容器则包含一些其他列。

我遇到的问题是左侧容器中横跨页面的 4 个小框有边距将它们向左和向右推。 4 个盒子需要与另一个顶部面板对齐。

此外,当我更改屏幕宽度时,4 个框不会保持为 4 个,它们会推出巨大的, 有什么好方法可以让他们的 react 不那么咄咄逼人吗?

请看我的fiddle attached

        <div class="col-lg-3 col-md-6 hero-feature">
        <div class="thumbnail">
            <img src="http://placehold.it/800x500" alt="">
            <div class="caption">
                <h3>Feature Label</h3>
                <p>This would be a great spot to feature some brand new products!</p>
                <p><a href="#" class="btn btn-primary">Buy Now!</a>  <a href="#" class="btn btn-default">More Info</a>
                </p>
            </div>
        </div>
    </div>

最佳答案

您的四个嵌套列比上面的面板缩进得更多的原因是您没有将嵌套列包装在 div.row 类中。

Updated jsFiddle here .

你的问题的第二部分与你使用的关于 BS3 的类有关。我会尝试以下操作,看看它是否会产生更好的响应:

<div class="col-lg-3 col-sm-6 hero-feature">
  <div class="thumbnail">
    <img src="http://placehold.it/800x500" alt="">
    <div class="caption">
      <h3>Feature Label</h3>
      <p>This would be a great spot to feature some brand new products!</p>
      <p><a href="#" class="btn btn-primary">Buy Now!</a>  <a href="#" class="btn btn-default">More Info</a></p>
    </div> <!-- /.caption -->
  </div> <!-- /.thumbnail -->
</div> <!-- /.col-lg-3.col-sm-6.hero-feature or nested column -->

请注意类从 .col-md-6 更改为 .col-sm-6

此外,如果您不希望主容器包装得那么快,请尝试将 .col-lg-10 替换为 .col-md-10 .col-sm-10。同时更新侧边栏,将 .col-lg-2 替换为 .col-md-10.col-sm-10,以两者为准大小由您决定。

jsFiddle for different container sizes .

关于html - 如何解决 Bootstrap 中的嵌套列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21535556/

相关文章:

javascript - 链接禁用属性在 Microsoft EDGE 浏览器中不起作用

html - 使用 bootstrap 并尝试创建一个容器,该容器占据导航栏底部和 View 末端之间 100% 的空间

javascript - Bootstrap 轮播,修改为显示多个元素。 Firefox 和 IE 无法正常工作

html - 使容器 div 高度和背景颜色随内容扩展

javascript - 优化jsp页面图片加载

javascript - 可靠地关闭 Webkit 通知

html - 隔离大量 CSS 文件以仅针对网站的一部分 (CMS)

javascript - 使用ajax在后台上传照片

html - 甚至分配固定大小的 div

css - 在站点之间链接到 Glyphicon 字体( Bootstrap )