Mostafa Norzade
Mostafa Norzade

Reputation: 1766

How to Reorder Columns with Bootstrap 4?

I have used the following tags in bootstrap 4 .

    <div class="container">
        <div class="row align-items-center">
            <div class="col-md-3">
                <div class="right-user-account" >
                    <a href="#">User Account</a>
                </div>
            </div>

            <div class="col-md-6">
                <img src="images/logo.png">
            </div>

            <div class="col-md-3">
                <div class="left-login" >
                    <a href="#">Login</a>
                </div>
            </div>
        </div>
    </div>

enter image description here

I want to be in full-width with the logo

enter image description here

How do I work with the reorder command?

Upvotes: 7

Views: 9744

Answers (2)

Saeed
Saeed

Reputation: 118

You can use reordering option of bootstrap
https://getbootstrap.com/docs/4.0/layout/grid/#reordering

Upvotes: 2

divy3993
divy3993

Reputation: 5810

Bootstrap 4 uses flex/flexbox. So yes you have the option of ordering elements/columns.

I think what you want is using just the Bootstrap-4 classes of order-{number} with your col classes.

Below is the solution:

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
  <div class="row align-items-center">
  
    <div class="col-md-3 col order-2 order-sm-1">
      <div class="right-user-account">
        <a class="fd-head-login" href="#">
          <i class="fa fa-caret-down"></i>User Account</a>
      </div>
    </div>
    
    <div class="col-md-6 text-center col-md-6 order-1 order-sm-2">
      <a href="#">
        <img src="images/logo.png">
      </a>
    </div>

    <div class="col-md-3 order-3">
      <div class="left-login">
        <a class="fd-head-login" href="#">Login<i class="fa fa-user"></i></a>
      </div>
    </div>
    
  </div>
</div>

You can find more here.

Codepen link to playaround screen widths

Hope this answer helps you!

Upvotes: 11

Related Questions