简体   繁体   English

Twitter Bootstrap:如何不将列缩放到767px以下的单行

[英]Twitter Bootstrap: how to not scale columns to single row under 767px

as you already know twitter bootstrap scales each span* to 100% width if you are on 767px and below. 如您所知,如果您使用的是767px及以下像素,twitter引导程序会将每个span *的宽度缩放至100%。 So, for instance, if we have two columns on 768px and above: 因此,例如,如果我们在768px及以上具有两列:

<div class="row">
    <div class="span6">Column 1</div>
    <div class="span6">Column 2</div>
</div>

this is the result: 结果是:

| column 1 | column 2 | <- desktops

on 767px and below they will collapse to: 在767px及以下像素,它们将折叠为:

| column 1 |   <- tablets, mobile
| column 2 |

and this is what's supposed to be. 这就是应该的。
But… how is you approach if you want this behavior for a row, but not for another? 但是……如果要连续这种行为而不是另一行为,您该如何处理?
How to left two (or more) columns even under 767px? 即使在767像素以下,如何保留两(或更多)列?

<div class="row">
    <div class="span6">Column 1</div>
    <div class="span6">Column 2</div>
</div>

<div class="special row">
    <div class="span6">Column 1</div>
    <div class="span6">Column 2</div>
</div>

| column 1 | column 2 | <- desktops
| column 1 | column 2 | 

| column 1 |   <- tablets, mobile
| column 2 |
| c1 |  c2 |

I'm really curious. 我真的很好奇

I've moved this to an answer while we wait to see if this is tagged with duplicate. 在我们等待看看是否有重复标签时,我已将其移至答案。

To get the two columns maintained within a mobile/tablet environment You're going to need to add another set of classes on the elements as well as some additional rules in your CSS. 要在移动/平板电脑环境中维护这两列,您将需要在元素上添加另一组类以及CSS中的一些其他规则。

By default all of the elements stack on mobile because a linear version is what we've come to expect. 默认情况下,所有元素都在移动设备上堆叠,因为我们一直期望线性版本。 If you check out http://foundation.zurb.com/docs/grid.php you can see that Zurb have also created another set of styles based on a 4 column mobile grid. 如果您查看http://foundation.zurb.com/docs/grid.php,您会发现Zurb还基于4列移动网格创建了另一组样式。 By adding these additional classes it allows you control your columns to occupy 1/3 1/2 2/3 full width. 通过添加这些其他类,您可以控制列占据1/3 1/2 2/3的全宽。

I've coded up a basic example for you to use -> http://playground.responsivedesign.is/twitter-bootstrap/ , but below are the details. 我已经编写了一个基本示例供您使用-> http://playground.sensitivedesign.is/twitter-bootstrap/ ,但以下是详细信息。

This is the markup you would add to your HTML (the additional .mobile-* classes) 这是您要添加到HTML中的标记(其他.mobile-*类)

 <div class="span4 mobile-one">...</div>
 <div class="span8 mobile-three">...</div>

or 要么

 <div class="span6 mobile-two">...</div>
 <div class="span6 mobile-two">...</div>

And the CSS that needs to be added is.. 和需要添加的CSS是..

.row-fluid .mobile-one {
  width: 31.491712707182323%;
  *width: 31.43852121782062%;
}

.row-fluid .mobile-three {
  width: 65.74585635359117%;
  *width: 65.69266486422946%;
}

.row-fluid .mobile-two {
  width: 48.61878453038674%;
  *width: 48.56559304102504%;
}

.row-fluid .mobile-one,
.row-fluid .mobile-two,
.row-fluid .mobile-three {
  float:left;
  margin-left: 2.7624309392265194%;
  *margin-left: 2.709239449864817%;
}

You have also asked whether it would also work with .row instead of using the .fluid-row . 您还询问了它是否也可以使用.row而不是使用.fluid-row It could do but there are some rules that come with the .fluid-row which are cascading so you will need to do a bit more trial and error work. 它可以做到,但是.fluid-row附带了一些级联的规则,因此您将需要做更多的反复试验。 My official stance would be to rethink your reasons for a pixel based static layout (albeit responsive with @media) and go with a fluid layout. 我的官方立场是重新考虑您基于像素的静态布局(尽管使用@media响应)的原因,并选择流畅的布局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM