2016-02-27 56 views
1

我有兩行和三列這樣操縱上自舉列和行的

[1] [2] [3]

[4] [5] [6]

我想他們看起來像這樣當我改變到移動視圖

[1] [2]

[3] [4]

[5] [6]

我已經嘗試過,但是當我更改爲移動視圖,它們會是這樣

[ 1] [2]

[3]

[4] [5]

[6]

如何操縱行和列? 謝謝。

回答

2

也許你正在使用兩行,這就是爲什麼你會得到這個結果。將它們全部放入一行並添加clearfixes特殊尺寸。

<!-- columns start at 50% wide on mobile and bump up to 33.3% wide on desktop --> 
<div class="row"> 
    <div class="col-xs-6 col-md-4">1</div> 
    <div class="col-xs-6 col-md-4">2</div> 

    <div class="clearfix visible-xs-block"></div> <!-- It works on mobile view --> 

    <div class="col-xs-6 col-md-4">3</div> 

    <div class="clearfix visible-md-block"></div> <!-- It works on desktop view --> 

    <div class="col-xs-6 col-md-4">4</div> 

    <div class="clearfix visible-xs-block"></div> <!-- It works on mobile view --> 

    <div class="col-xs-6 col-md-4">5</div> 
    <div class="col-xs-6 col-md-4">6</div> 
</div> 

現在,你將有:

[1] [2] [3]

[4] [5] [6]

桌面視圖和

[1] [2]

[3] [4]

[5] [6]

移動視圖。

+0

hi @kaan btw如何實現到rails?當我在rails中使用它時遇到了問題。如何把'

'和'
'?我應該把它們放到循環中嗎?檢查[此鏈接](http://stackoverflow.com/questions/37046895/how-to-implement-style-in-html-col-to-rails/37048149#37048149)我的查看代碼。謝謝 – June