Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

html - Change column order in mobile view

I would like to change the vertical order of 2 columns on a page in mobile view, so that column 2 goes first and column 1 follows.

The current order is that column 1 goes first and column 2 goes second, both in mobile and desktop view. In mobile view, the columns are stacked vertically, which is how I want to keep them, only in different order.

I tried using float, but something in the template's CSS is overriding the customizations. Here is a test page, and here is the HTML.

<body class="theme-invert">
    <div class="container">
        <div class="row-fluid">         
            <section class="section">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-4 col-sm-offset-1">
                            <div class="panel panel-default">
                                <div class="panel-body">        
                                    <h2>Column 1</h2>                                           
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="panel panel-default">
                                <div class="panel-body"> 
                                    <h2>Column 2</h2>                             
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>

Edit: this is different from the question suggested in the comments because that starts out with columns in the same class, whereas my columns are already in different classes, but I still haven't been able to get them to behave differently in mobile view.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just give your col-sm-4 a float:right and start playing with CSS until it looks like it should.

See this crappy fiddle where I just copied all your stuff and added the first line:

.col-sm-4 {float:right !important}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...