Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Justify Content for different break points Bootstrap 4 [duplicate]

Tags:

bootstrap-4

How can I justify content of a column for different breakpoints. For example, I want the following email text to be justified to the end for > medium columns but justified to the centre for smaller columns. Looking for an elegant solution.

<div class="row">
            <div class="col-md-4">
              Email
            </div>
</div>
like image 461
D.B Avatar asked Apr 15 '18 09:04

D.B


People also ask

What is Col SM 4 in Bootstrap?

col-sm-4 are available for quickly making grid layouts. Columns create gutters (gaps between column content) via padding. That padding is offset in rows for the first and last column via negative margin on .

What is Bootstrap 4's smallest breakpoint?

Responsive breakpoints // Extra small devices (portrait phones, less than 576px) // No media query for `xs` since this is the default in Bootstrap // Small devices (landscape phones, 576px and up) @media (min-width: 576px) { ... } // Medium devices (tablets, 768px and up) @media (min-width: 768px) { ... }

What is XL in Bootstrap?

Extra large devices are defined as having a screen width from 1200 pixels and above.

How do I make 5 columns in Bootstrap 4?

Populate the 'row' div with 5 divs with class 'col'. Because Bootstrap 4.0+ grid system has now shifted to Flexbox, the columns will arrange by themselves into five equally sized DOM elements.


1 Answers

To position the content of the column div you can use the responsive versions of justify-content-* class with d-flex

<div class="row">
    <div class="col-md-4 d-flex justify-content-md-end justify-content-center">
      Email
    </div>
</div>

Just add the classes d-flex to display flex and justify-content-md-end to align at the end of the column for display md and upwards and justify-content-center to align to center for display xs and upwards.

Demo

like image 106
Shiblu Avatar answered Oct 17 '22 11:10

Shiblu