为什么我的流体 cols 在中等尺寸时会破裂?
Why is my fluid cols breaking at medium size?
我是一名高中网页设计老师,目前正在教我的学生如何构建自己的网格框架。我正在使用浮动 .col 方法,因为它很容易理解,并且从浮动和清除的教学中可以很好地理解。接下来我将转向 flexbox。
我遇到了一个奇怪的问题。在中等尺寸的屏幕上,只有断点内的某些尺寸,网格似乎 'break' 并且最后一个 .col 下降到下一行。这是显示它的 link 到 JS Fiddle。
这里是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*/
是否有 class 我需要构建并添加到其中?或者我可以改变我构建 cols 的方式来完全避免这种情况吗?我仿照 Bootstrap 3.
看起来这是从 'Mark Locations' 复制中断到比它旁边的模块更多的行。
我可以通过在 col 声明中添加一个最小高度为 220 像素的 class 来解决这个问题。
.icon-height {
min-height: 220px;
}
<div class="col-lg-3 col-md-6 icon-height">
我是一名高中网页设计老师,目前正在教我的学生如何构建自己的网格框架。我正在使用浮动 .col 方法,因为它很容易理解,并且从浮动和清除的教学中可以很好地理解。接下来我将转向 flexbox。
我遇到了一个奇怪的问题。在中等尺寸的屏幕上,只有断点内的某些尺寸,网格似乎 'break' 并且最后一个 .col 下降到下一行。这是显示它的 link 到 JS Fiddle。
这里是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*/
是否有 class 我需要构建并添加到其中?或者我可以改变我构建 cols 的方式来完全避免这种情况吗?我仿照 Bootstrap 3.
看起来这是从 'Mark Locations' 复制中断到比它旁边的模块更多的行。
我可以通过在 col 声明中添加一个最小高度为 220 像素的 class 来解决这个问题。
.icon-height {
min-height: 220px;
}
<div class="col-lg-3 col-md-6 icon-height">