Bootstrap aligment问题

时间:2017-01-24 19:01:17

标签: html css twitter-bootstrap

我试图将一些元素与bootstrap对齐,但我们之间存在着奇怪的差距。我可以问你一些建议吗? 这是布局结构的最终图片。

enter image description here

这是我的代码,直到现在



 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
   
<section class="product-list">
  <div class="container">
    <div class="row">
      <div class="col-md-3">
        <div class="catalog">
          <ul class="catalog-list">
            <li>
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
            </li>
          </ul>
        </div>
        <!-- catalog -->
      </div>
      <div class="col-md-3">
        <div class="catalog">
          <ul class="catalog-list">
            <li>
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
            </li>
          </ul>
        </div>
        <!-- catalog -->
      </div>
      <div class="col-md-6">
        <div class="laptops">
          <img src="https://s27.postimg.org/ottosbaw3/example2.jpg" width="548" height="545" title="someText" alt="someText">
        </div>
      </div>
    </div>
    <!-- row -->
    <div class="row">
      <div class="col-md-3">
        <ul class="catalog-list">
          <li>
            <a href="#">
              <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
            </a>
          </li>
        </ul>
      </div>
      <div class="col-md-3">
        <ul class="catalog-list">
          <li>
            <a href="#">
              <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
            </a>
          </li>
        </ul>
      </div>
    </div>
    <!-- row -->
  </div>
  <!-- container -->
</section>
<!-- product-list -->
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:1)

假设我理解正确,你的html太多了。绝对没有必要将单个图像包装到列表中。

全屏查看,我没有添加小型显示类。

.margin{margin-bottom: 25px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
   
<section class="product-list">
  <div class="container">
    <div class="row">
      <div class="col-md-6">
        <div class="row margin">
      <div class="col-md-6">
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
      </div>
      <div class="col-md-6">
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
      </div>
          </div>
        <div class="row">
      <div class="col-md-6">
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
      </div>
      <div class="col-md-6">
              <a href="#">
                <img src="https://s23.postimg.org/mjrt9w557/example.jpg" width="260" height="260" title="someText" alt="someText">
              </a>
      </div>
          </div>
        </div>
      <div class="col-md-6">
        <div class="laptops">
          <img src="https://s27.postimg.org/ottosbaw3/example2.jpg" width="548" height="545" title="someText" alt="someText">
        </div>
      </div>
    </div>
  </div>
  <!-- container -->
</section>
<!-- product-list -->

答案 1 :(得分:0)

如果我理解你的问题是正确的,你会想知道这些元素之间的差距。 Bootstrap在名为 gutter 的列之间应用填充。如果您不希望列之间存在间隙,则可能需要调整装订线边距和边距。

http://getbootstrap.com/css/#grid-options

答案 2 :(得分:0)

使用两个col-md-6并在第一个col-md-6内部使用具有特定高度的4 col-md-6,您的问题就解决了。