简体   繁体   English

使用Bootstrap 3流体网格“旋转”布局

[英]“Pivoting” a layout with Bootstrap 3 fluid grid

I'm just starting with Bootstrap 3 and struggling to find a fluid (responsive) solution for the required grid. 我只是从Bootstrap 3开始,努力寻找所需网格的流畅(响应)解决方案。

Simplified it should look like the following 简化后应如下所示

for desktop and tablets: 适用于台式机和平板电脑:

------------+---------------+-----------
 Label 1.1   Label 2.1       Label 3.1 
 Label 1.2   Label 2.2       Label 3.2

for phones : 手机

----------+----------
 Label 3.1  Label 3.2     
 Label 2.1  Label 2.2
 Label 1.1  Label 1.2

As you can see the components need to be stacked in 3 columns on a larger screens while forming 3 lines with 2 columns each on smaller ones. 如您所见,组件需要在较大的屏幕上堆叠成3列,而在较小的列上形成3行,每行2列。

I unsuccessfully tried three blocks with a pair of components in each like the one below. 我尝试了三个块,每个块中都有一对组件,但均未成功,如下所示。 They are all wrapped into a container and a row . 它们全都包裹在一个containerrowrow

   <div class="col-md-4 ">
       <div class="col-lg-12 col-md-12 col-sm-6 col-xs-6">
           <label>Label 1.1</label.1>
           <label>Label 2.1</label>
       </div> 
    </div>

I also tried to splitting each label into it's own <div class="col-sm-6"> and it didn't work for me as well. 我还尝试将每个标签拆分为自己的<div class="col-sm-6"> ,但它对我也不起作用。

On top of it (as you can see), the order needs to be reversed vertically. 在其顶部(如您所见),需要垂直反转顺序。 I was thinking about push and pull but they work horizontally. 我当时在考虑pushpull但它们是横向工作的。

Is it even possible with pure Bootstrap (no custom CSS). 甚至有可能使用纯Bootstrap(无自定义CSS)。 Am I missing something basic here? 我在这里缺少基本的东西吗? Please point me into the right direction. 请指出正确的方向。

EDIT: (03/26/2014) 编辑: (03/26/2014)

I believe that I found a solution to a reverse ordering. 我相信我找到了解决逆序问题的方法。 Create sm layout with the appropriate order and then use push and pull to swap 1st and 3rd fields in each row in a horizontal layout on md and lg devices. 以适当的顺序创建sm布局,然后使用pushpullmdlg设备的水平布局中交换每行的第一和第三字段。

Still not sure how to achieve the desired layouts organically (ie without field duplication with visible and hidden classes). 仍然不确定如何有机地实现所需的布局(即,没有具有visible类和hidden类的字段重复)。

Assuming I didn't miss anything, this matches your two layouts specified: 假设我什么都没错过,这与您指定的两个布局匹配:

<div class='row'>
    <div class='col-xs-12 col-sm-4 pull-right'>
        <div class='col-xs-6 col-sm-12'>3.1</div>
        <div class='col-xs-6 col-sm-12'>3.2</div>
    </div>
    <div class='col-xs-12 col-sm-4 pull-right'>
        <div class='col-xs-6 col-sm-12'>2.1</div>
        <div class='col-xs-6 col-sm-12'>2.2</div>
    </div>
    <div class='col-xs-12 col-sm-4 pull-right'>
        <div class='col-xs-6 col-sm-12'>1.1</div>
        <div class='col-xs-6 col-sm-12'>1.2</div>
    </div>
</div>

As you can see, you use the pull-right to make the top pull to the right, which essentially reverses the order when stacked. 如您所见,您可以使用向右拉动使顶部向右拉动,从而在堆叠时实质上颠倒了顺序。

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

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