Bootstrap网格在某些点上正在破裂

时间:2018-01-06 06:49:12

标签: bootstrap-4

我正在制作一个带有引导网格系统的博客应用程序。它适用于小型,中型和大型屏幕。图片如下:

Large screen

Medium screen

Small screen

但在中小屏幕之间,网格完全断开

这是我的HTML / ejs代码。我正在填充博客模型中的列

<center><h1>Blogs</h1></center>

<div class="container">
   <div class="row content">
      <% blogs.forEach(function(blog){ %>
      <div class="col col-sm-2 col-md-4 col-lg-4">
         <div class="card">
            <img src="<%= blog.image %>">
            <h4><%=blog.name%></h4>
            <p><%=blog.description %></p>
            <a href="/blogs/<%= blog._id %>" class="blue-button">Read More</a>
         </div>
      </div>
      <% }); %>
   </div>
</div>

这是我的CSS

.row{
    margin-top:20px;
}

 .card{
    background-color: #FFFFFF;
    padding:0;
    margin-top:20px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius:4px;
    box-shadow: 0 4px 5px 0 rgba(0,0,0,0.14), 0 1px 10px 0 rgba(0,0,0,0.12), 0 2px 4px -1px rgba(0,0,0,0.3);

}
 .card:hover{
    box-shadow: 0 16px 24px 2px rgba(0,0,0,0.14), 0 6px 30px 5px rgba(0,0,0,0.12), 0 8px 10px -5px rgba(0,0,0,0.3);
    color:black;
}
.card img{
    width:100%;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    height:250px;
}
 .card h4{
    margin:20px;
}
 .card p{
    margin:20px;
    opacity: 0.65;
    text-overflow: ellipsis;
    word-wrap: break-word;
    overflow: hidden;
    max-height: 3.6em;
    line-height: 1.8em;
}
 .blue-button{
    width: 100px;
    -webkit-transition: background-color 1s , color 1s; 
    transition: background-color 1s , color 1s;
    min-height: 20px;
    background-color: #002E5B;
    color: #ffffff;
    border-radius: 4px;
    text-align: center;
    font-weight: lighter;
    margin: 0px 20px 15px 20px;
    padding: 5px 0px;
    display: inline-block;
}
.blue-button:hover{
    background-color: #dadada;
    color: #002E5B;
}

1 个答案:

答案 0 :(得分:0)

问题在评论中得到解决:

班级col-sm-2需要更改为col-sm-6