简体   繁体   English

引导网格系统

[英]Bootstrap Grid System

The project I'm working on has a blog, makes use of bootstrap grid system. 我正在从事的项目有一个博客,它使用了引导网格系统。 3 blog posts in a row, Code : 连续3个博客文章,代码:

<div class="container">

    <div class="row">

    <a href="/blog"><h4>News</h4></a>

      <% blog.forEach(function(blog) { %> // Creates a blog and adds a title, image and body to it
      <div class="col-md-4 col-sm-6">

        <div class="thumbnail">
            <img src="<%= blog.image %>">  //Adds image
        </div>

        <div class="caption">
            <a href="#"><h4><%= blog.title %></h4></a>  //Adds image
        </div>

        <span><%= blog.created %></span>

        <div class="relative">
          <p><%- blog.body %></p>  //Adds body content
          <div class="absolute"></div>
        </div>
        <a href="/blog/<%= blog._id %>">Read More</a>

        </div>

        <% }) %>

    </div>

This is how it currently looks : 这是当前的样子:

As described in the image, the 4th item gets created and takes the middle space (which should not happen). 如镜像所描述,第四个项目被创建并占据中间空间(这不应发生)。 It should take the previous (available) space. 它应该占用前一个(可用)空间。 I've tried "float" property, but shouldn't it automatically be done that way(by Bootstrap)? 我已经尝试过“ float”属性,但是不应该那样做吗(通过Bootstrap)? Any work-around? 任何解决方法?

This might be due to you row not having only columns underneath it. 这可能是由于您的行下面没有仅列。 You have an tag before you columns which may interfere. 列之前有一个标签,可能会造成干扰。 Try moving it outside the div.row. 尝试将其移到div.row之外。

<div class="container">
    <a href="/blog"><h4>News</h4></a>

    <div class="row">
      <% blog.forEach(function(blog) { %> // Creates a blog and adds a title, image and body to it
      <div class="col-md-4 col-sm-6">

        <!-- Rest of the column -->

        </div>

    <% }) %>

    </div>
</div>

Also if the first column is higher than the rest, it moves the fourth column to the middle, so make sure your div.col-* are the same height 另外,如果第一列高于其余列,则会将第四列移到中间,因此请确保div.col- *的高度相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM