Article push/pull alignment using bootstrap 3

后端 未结 4 813
说谎
说谎 2020-12-18 06:41

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. T
相关标签:
4条回答
  • 2020-12-18 07:15

    it's your columns class:

    md: 4 (image) - 8 (title) => 1st row (max 12 columns)
    8 (content) => new row

    that's will make a new row, the 2nd row placed below image/title column
    so you must use this columns setting (using hidden class) like this:

    md: 2 (image) - 5 (title) - 5 (hidden-xs hidden-sm)
    5 (content)

    just try this code:

    CSS:

    <style>
            .col-md-2{
                height: 300px;
                background-color: blue;
                color: white;
                border: 2px solid red;
            }
            .col-md-4{
                height: 100px;
            }
            .col-md-5{
                height: 100px;
                background-color: red;
                color: white;
                border: 2px solid black;
            }
    </style>
    

    HTML:

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

    maybe it's not solve the problem. but you can use this trick.
    sorry for my bad english

    0 讨论(0)
  • 2020-12-18 07:16

    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>
    
    0 讨论(0)
  • 2020-12-18 07:22

    Here's how fix the problem

    <article class="row">
        <header class="col-md-8 pull-right">
            <a href="#">
                <h2>Title</h2>
            </a>
        </header>
        <div class="col-md-4 pull-left">
            <figure>
                <a class="thumbnail" href="#">
            <img src="..." alt="4x3 Image" class="img-responsive">
                    <figcaption>...</figcaption>
                </a>
            </figure>    </div>
        <div class="col-md-8 pull-right">
            <p>content</p>
        </div>
    </article>
    
    0 讨论(0)
  • 2020-12-18 07:32

    Use a bigger div with col-md-8 class and place title and text inside it and use bootstrap's col-md-12 class on both of them to stack over one another

    0 讨论(0)
提交回复
热议问题