Twitter的Bootstrap 3.x语义移动网格 [英] Twitter's Bootstrap 3.x semantic mobile grid

查看:54
本文介绍了Twitter的Bootstrap 3.x语义移动网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了新的(未完成的) Bootstrap 3文档之后,我想知道如何创建语义移动网格.

After reading the new (unfinished) Bootstrap 3 docs I am wondering how to create semantic mobile grid.

简而言之.如何转换:

<div class="row">
  <div class="col col-lg-6 col-sm-6">6</div>
  <div class="col col-lg-6 col-sm-6">6</div>
</div>

为此,并保留小型移动网格:

To this and preserve the small mobile grid:

<div class="wrapper">
  <div class="left">6</div>
  <div class="right">6</div>
</div>

较少

.wrapper {  .make-row(); }
.left    { .make-column(6); // this creates only large grid }
.right   { .make-column(6); }

推荐答案

如果我很好地理解了您的问题,我认为您应该使用:

If i understand your question well i think you should use:

<罢工>
<div class="row"> <div class="col-span-6 col-small-span-6″>6</div> <div class="col-span-6 col-small-span-6″>6</div> </div>


<div class="row"> <div class="col-span-6 col-small-span-6″>6</div> <div class="col-span-6 col-small-span-6″>6</div> </div>

其中col-span-6是大网格的类,而col-small-span-6是小网格的类.如果您离开col-small-span-6,则div将堆叠.小网格不使用col-span-*类.

Where col-span-6 is your class for the large grid and col-small-span-6 for the small grid. If you leave col-small-span-6 your div will stack. The small grid don't use the col-span-* classes.

另请参见:从现在开始,Twitter的Bootstrap定义了三个网格:用于电话的微小网格(<480px),用于平板电脑的小网格(<768px)和用于Destkops的中型网格(> 768px).这些网格的行类前缀为".col-",.col-sm-"和".col-lg-".中型网格将堆叠在768像素以下的屏幕宽度上.低于480像素的小网格也不会堆叠.

From now Twitter’s Bootstrap defines three grids: Tiny grid for Phones (<480px), Small grid for Tablets (<768px) and the Medium-large grid for Destkops (>768px). The row class prefixes for these grid are ".col-", ".col-sm-" and ".col-lg-". The Medium-large grid will stack below 768 pixels screen width. So does the Small grid below 480 pixels and the tiny grid never stacks.

因此您的html应该是:

So your html should be:

<div class="row">
  <div class="col-6 col-lg-6 col-sm-6">6</div>
  <div class="col-6 col-lg-6 col-sm-6">6</div>
</div>

最新版本: https://github.com/twitter /bootstrap/archive/3.0.0-wip.zip 不再包含.make-small-column函数.另请参见:

LESS The latest version: https://github.com/twitter/bootstrap/archive/3.0.0-wip.zip doesn't contain a .make-small-column function any more. See also: https://github.com/twbs/bootstrap/pull/8302 .make-column() will add a media query for min-width: @grid-float-breakpoint so on the small grid your columns will stack always using this function.

您可以尝试:

// Generate the small columns
.make-small-column(@columns) {
  position: relative;
  float: left;
  // Prevent columns from collapsing when empty
  min-height: 1px;
  // Inner gutter via padding
  padding-left:  (@grid-gutter-width / 2);
  padding-right: (@grid-gutter-width / 2);
  @max : (@grid-float-breakpoint - 1 );
  // Calculate width based on number of columns available
  @media (max-width: @max) {
    width: percentage((@columns / @grid-columns));
  }
}

.wrapper {  .make-row(); }
.left    { .make-column(6); .make-small-column(6);}
.right   { .make-column(6); .make-small-column(6);}

更新

以上答案将基于Twitter的Bootstrap 3的发布候选版本.Twitter的Bootstrap 3的最终版本具有4个网格额外的小(xs),小(sm),中(md)和大(lg).而且,Less代码已根据这些网格进行了更改.因此,请使用@gravy在他的答案中描述的.make- {x}-列mixins: https://stackoverflow.com/a /18667955/1596547

The answer above will be based on the release candidates of Twitter's Bootstrap 3. The final version of Twitter's Bootstrap 3 has 4 grid extra small (xs), small (sm), medium (md) and large (lg). Also the Less code has been change according these grids. So use the .make-{x}-column mixins as described by @gravy in his answer: https://stackoverflow.com/a/18667955/1596547

这篇关于Twitter的Bootstrap 3.x语义移动网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆