Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

css - Article push/pull alignment using bootstrap 3

I'm using bootstrap 3 and I try to have a specific grid alignment for article on desktop.

On mobile I want to order content of the article like that :

  1. Title
  2. Image
  3. Content

On desktop, I want the image on the left and the title and content on the right.

Alignment i want

Here is my code

<article class="row">
    <header class="col-md-8 col-md-push-4">
        <a href="#">
            <h2>Title</h2>
        </a>
    </header>
    <div class="col-md-4 col-md-pull-8">
        <figure>
            <a class="thumbnail" href="#">
        <img src="..." alt="4x3 Image" class="img-responsive">
                <figcaption>Caption</figcaption>
            </a>
        </figure>
    </div>
    <div class="col-md-8 col-md-push-4">
        <p>Content</p>
    </div>
</article>

But with this code, the content is on the right but under the image.

Is there a simple way to get what I want ?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Based on Possible to achieve this Mobile/Desktop layout using Bootstrap? (or other grid)

css:

.floatright{float:right;}
@media (max-width: 768px)
{    
    .floatright{float:none;}
}  

html:

<div class="container" style="background-color:green">
<article class="row">
    <header class="col-md-8 floatright">
        <a href="#">
            <h2>Title</h2>
        </a>
    </header>
    <div class="col-md-4">
        <figure>
            <a class="thumbnail" href="#">
        <img src="..." alt="4x3 Image" class="img-responsive">
                <figcaption>Caption</figcaption>
            </a>
        </figure>
    </div>
    <div class="col-md-8 floatright">
        <p>Content</p>
    </div>
</article>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...