georg
georg

Reputation: 215059

Span the content area across multiple rows

I'm trying to create a layout like this:

enter image description here

http://jsfiddle.net/LLbnhb9v/

Basically, A and C are sidebar items, and B is the main content:

My markup is as follows:

<div class="container">
    <div class="col-sm-2">
        A
    </div>
    <div class="col-sm-8">
        B
    </div>
    <div class="col-sm-2">
        C
    </div>
</div>

This works for the mobile, but on the desktop C is positioned below B. How can I make B (the main content) "span" across multiple rows without any insane css tricks?

Upvotes: 3

Views: 72

Answers (1)

Joey
Joey

Reputation: 1370

You need to have the pink section have the pull-right class and the green section to have a clearfix class. http://jsfiddle.net/LLbnhb9v/19/

<div class="container">
    <div class="col-sm-2">
        <div class="x a">
            short<br>text
        </div>
    </div>
    <div class="col-sm-10 pull-right">
        <div class="x b">
            Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?"
        </div>
    </div>
    <div class="col-sm-2 clearfix">
        <div class="x c">
            short<br>text
        <div>
    </div>
</div>

I also changed the layout a little bit. The first level of divs should only worry about layout. If you add padding and margins and stuff then they can have some issues and not work as expected. I moved the a b c and x classes onto sub elements.

Upvotes: 3

Related Questions