Elliott Davidson Elliott Davidson -4 years ago 110
CSS Question

Bootstrap column stacking on mobile

Im trying to get the col-md-6 to stack below the col-md-4 on mobile but cant get it to work. Any advice how to achieve this would be great.

<footer>

<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-1 col-xs-12">
<?php
wp_nav_menu( array(
'menu' => 'footer',
'theme_location' => 'footer',
'depth' => 1,
'container' => 'div',
'container_id' => 'footer-nav',
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
</div>
<div class="col-md-4 col-xs-12 copyright-text">
<p>Copyright © <?php echo date("Y"); ?> Elliott Davidson. All Rights Reserved.</p>
</div>
</div>
</div>



Answer Source

You could look into using order property from utilizing flexbox. Check out the documentation here.

What you'd do is something like this:

<div class="container">
  <div class="row flex">
    <div class="col-md-6 col-md-offset-1 col-xs-12 first">Div 1</div>
    <div class="col-md-4 col-xs-12 copyright-text second">Div2</div>
  </div>
</div>


/* Make sure to use all the proper prefixers */
/* Allow this to be up to mobile of 767px */
@media all and ( max-width: 767px ) {
    .flex { display: flex; }
    .first { order: 2; }
    .second { order: 1; }
}

Take a look at this codepen which will have a solution for you.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download