【发布时间】:2018-02-23 17:41:05
【问题描述】:
我已经构建了一个自定义网格,其内容类似于Creating Your Own CSS Grid System 上的内容。
当我尝试将两行中的四个项目显示为每列两列时(tablet-col-6),前两个项目将正确对齐,但第三个项目将未对齐,第四个项目位于另一行.这主要是由于每列的列具有不同的高度。不能使用 Bootstrap 的网格系统。
我该如何解决这个问题?
.container {
width: 100%;
max-width: 1200px;
}
.container * {
box-sizing: border-box;
}
.row:before,
.row:after {
content:"";
display: table;
clear:both;
}
[class*='col-'] {
float: left;
min-height: 1px;
padding: 16px;
}
@media screen and (min-width: 320px) {
.mobile-col-12 {
width: 100%;
}
}
@media screen and (min-width: 768px) {
.tablet-col-6 {
width: 50%;
}
}
@media screen and (min-width: 1200px) {
.desktop-col-12 {
width: 25%;
}
}
.border {
border: 1px solid black;
}
<div class="container outline">
<div class="row">
<div class="mobile-col-12 tablet-col-6 desktop-col-3 border">Compellingly expedite intermandated paradigms via out-of-the-box architectures. Enthusiastically transition vertical networks after multimedia based best practices. Completely predominate principle-centered.</div>
<div class="mobile-col-12 tablet-col-6 desktop-col-3 border">Enthusiastically benchmark cooperative information through proactive methods of empowerment. Completely syndicate alternative.</div>
<div class="mobile-col-12 tablet-col-6 desktop-col-3 border">Progressively recaptiualize quality convergence through extensive innovation. Uniquely utilize.</div>
<div class="mobile-col-12 tablet-col-6 desktop-col-3 border">Proactively pursue quality leadership skills with innovative processes. Quickly actualize dynamic.</div>
</div>
</div>
电流输出
期望的输出
【问题讨论】:
-
那篇基于浮点数重新网格化的文章有点老了。您可能想查看this article,也许还有this very well done video。这是另一个article worth reviewing
-
@gibberish 我将把它转换成使用 flexbox 看看会发生什么,我会尽快发布更新