我是一名高中网页设计老师,目前正在教我的学生如何建立他们自己的网格框架。我正在使用浮动.col方法,因为它易于理解,并且从教导浮动和清除方面流畅。我接下来要转向flexbox。
我遇到了一个奇怪的问题。在中等大小的屏幕上,并且在该断点内只有一定的尺寸,网格似乎“突破”。最后一个.col下降到下一行。以下是显示该JS Fiddle的http://localhost:8080/的链接。
这是HTML
<!-- Link to Font Awesome v4 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<!-- Section from page that is 'breaking' at certian md sizes -->
<section id="features">
<div class="container">
<div class="row">
<div class="col-lg-3 col-md-6">
<i class="fa fa-map-marker" aria-hidden="true"></i>
<h2>Mark Locations</h2>
<p>Mappy lets you save important locations like home, work, or even where you parked your car!</p>
</div>
<div class="col-lg-3 col-md-6">
<i class="fa fa-map" aria-hidden="true"></i>
<h2>View Full Maps</h2>
<p>Mappy also lets your look at up-to-date maps of towns, cities, and even the globe! </p>
</div>
<div class="col-lg-3 col-md-6">
<i class="fa fa-map-signs" aria-hidden="true"></i>
<h2>Get Directions</h2>
<p>Let Mappy guide you where you want to go! Simply enter an address or location and Mappy will find the best route</p>
</div>
<div class="col-lg-3 col-md-6">
<i class="fa fa-car" aria-hidden="true"></i>
<h2>Realtime Traffic</h2>
<p>Mappy is connected to local traffic updates, so it can always provide the fastest route to avoid jams</p>
</div>
</div>
</div>
</section>
和CSS
/* CUSTOM PAGE CSS*/
#features {
padding: 20px 0;
text-align: center;
}
#features i.fa {
color: #683814;
font-size: 70px;
}
#features h2 {
color: #DCD39E;
margin: 15px 0;
}
/* PULLED FROM CUSTOM GRID FRAMEWORK */
* {
box-sizing: border-box;
}
.container {
max-width: 1000px;
margin: auto;
padding: 0 20px; /*Adds a tiny bit of padding so that as the container shrinks it does not touch the edge*/
}
/* ROWS */
/* Build clearfix into row */
.row::after {
content: "";
display: block;
clear: both;
}
.row {
margin: 0 -15px; /*Offset the col-* padding*/
}
/* COLS */
/*Mobile First cols*/
[class*="col-"] {
width: 100%;
float: left;
padding: 10px 15px;
}
/*Col Styles For Tablets*/
@media screen and (min-width:600px) and (max-width: 992px) {
.col-md-1 {width: 8.33%;}
.col-md-2 {width: 16.66%;}
.col-md-3 {width: 25%;}
.col-md-4 {width: 33.33%;}
.col-md-5 {width: 41.66%;}
.col-md-6 {width: 50%;}
.col-md-7 {width: 58.33%;}
.col-md-8 {width: 66.66%;}
.col-md-9 {width: 75%;}
.col-md-10 {width: 83.33%;}
.col-md-11 {width: 91.66%;}
.col-md-12 {width: 100%;}
} /*end tablet*/
/*Col Styles For Desktops*/
@media screen and (min-width:993px) {
.col-lg-1 {width: 8.33%;}
.col-lg-2 {width: 16.66%;}
.col-lg-3 {width: 25%;}
.col-lg-4 {width: 33.33%;}
.col-lg-5 {width: 41.66%;}
.col-lg-6 {width: 50%;}
.col-lg-7 {width: 58.33%;}
.col-lg-8 {width: 66.66%;}
.col-lg-9 {width: 75%;}
.col-lg-10 {width: 83.33%;}
.col-lg-11 {width: 91.66%;}
.col-lg-12 {width: 100%;}
} /*End Desktop*/
我需要构建一个类并添加到此类吗?或者是否有一些我可以改变的方式我建立cols以完全避免这种情况?我在Bootstrap 3之后对此进行了建模。
答案 0 :(得分:2)
看起来这是来自Mark Locations&#39;复制到比其旁边的模块更多的行。
我能够通过在col声明中添加一个最小高度为220px的类来解决这个问题。
.icon-height {
min-height: 220px;
}
<div class="col-lg-3 col-md-6 icon-height">