【问题标题】:bootstrap nesting columns in a short-div在短 div 中引导嵌套列
【发布时间】:2015-07-10 19:08:34
【问题描述】:

我对 bootstrap 还很陌生,我正在尝试在所附图像中实现类似的效果,但我无法显示文本区域 3 &4。

下面是我的代码 欢迎任何建议。我也在寻找关于网格系统的好教程 这是图片的链接

<div class="container-fluid">
    <div class="jumbotron">
        <center>
            <h1>Bootstrap Tutorial</h1>

            <p>
                Bootstrap is the most popular HTML, CSS, and JS framework for developing
                responsive, mobile-first projects on the web.
            </p>

            <input type="button" class="btn btn-info" value="Order service ">

        </center>

    </div>
</div>


<div class="container-fluid">
    <div class="row">
        <div class="col-lg-8 col-md-8 col-sm-8" >


            <!-- first row 8 div-->
            <div class="short-div">
                <div class="well well-sm">
                    Bootstrap is the most popular HTML, CSS, and JS framework for developing
                    responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing
                    responsive, mobile-first projects on the web.
                </div>
            </div>

            <!-- second row 8 div-->
            <div class="short-div">
                <div class="well well-sm">
                    Bootstrap is the most popular HTML, CSS, and JS framework for developing
                    responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing
                    responsive, mobile-first projects on the web.
                </div>
            </div>


              <!-- third row 8 div-->
            <div class="short-div">

                <!--left 4 div-->
                <div class="col-md-4 col-sm-4" style="background-color:forestgreen">

                </div>

                <!--right 4 div-->
                <div class="col-md-4 col-sm-4" style="background-color:blue">

                </div>

            </div>
                </div>
        </div>
    </div>
</div>

【问题讨论】:

  • @Cthulhu 在网站上拥有 1.4k 的声誉,您必须正确地看到问题,并注意只有 1 个代表的人不能发布图片!
  • 我现在添加了附件图片的链接

标签: css twitter-bootstrap grid nested


【解决方案1】:

请记住,当您要细分一行时,您需要计算相对于父元素的 12 格系统的宽度,而不是 body。

使用col-md-6 而不是col-md-4,因为它将父元素分成列而不是三列。

您需要的布局在下面的代码中:

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="container-fluid">
  <div class="jumbotron">
    <center>
      <h1>Bootstrap Tutorial</h1>

      <p>
        Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.
      </p>

      <input type="button" class="btn btn-info" value="Order service ">

    </center>

  </div>
</div>


<div class="container-fluid">
  <div class="row">
    <div class="col-lg-8 col-md-8 col-sm-8">


      <!-- first row 8 div-->
      <div class="short-div">
        <div class="well well-sm">
          Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.
        </div>
      </div>

      <!-- second row 8 div-->
      <div class="short-div">
        <div class="well well-sm">
          Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.
        </div>
      </div>


      <!-- third row 8 div-->
      <div class="short-div">

        <!--left 4 div-->
        <div class="col-xs-6 col-md-6 col-sm-6 well">
          Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.
        </div>

        <!--right 4 div-->
        <div class="col-xs-6 col-md-6 col-sm-6 well">
          Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web. Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile-first projects on the web.
        </div>

      </div>
    </div>
  </div>
</div>

【讨论】: