I have a row with a dynamic count of columns that is generated in JADE based on data fetched from the database. Items are image and the count of them can be 0 and can be a large number (max 100).
The .row is inside of a frame and I want to be able to populate the images in a right-to-left orders. Meaning, first image is at the top-right corner, second one is to the left of the first. each image uses col-md-2 so after 6 images the 7th should be under the first one.
Right now, when generating the columns the first one is at the top-left corner.. as it's the default.
Any way to change that?
Tried using col-md-offset-X and it's only effecting the first line of images (because it's a single row)
Current:
--------------
| x x x x |
| x x |
--------------
How it should be:
--------------
| x x x x |
| x x |
--------------
In bootstrap 4, if you want the columns of a row to start from right to left and you set multiple column classes on a div, I suggest an easy solution by adding justify-content-end to the row enclosing the columns.
To move columns to the right, use the . col-*-offset-* class in Bootstrap.
Write the columns in an order, and show them in another one. You can easily change the order of built-in grid columns with . col-md-push-* and . col-md-pull-*modifier classes where * range from 1 to 11.
Use .flex-row to set a horizontal direction (the browser default), or .flex-row-reverse to start the horizontal direction from the opposite side. Use .flex-column to set a vertical direction, or .flex-column-reverse to start the vertical direction from the opposite side.
To reach your goal you have to change floating in .col-md-2
. If necessary use !important
.
.col-md-2 {
float: right !important;
}
DEMO
In bootstrap 4, if you want the columns of a row to start from right to left and you set multiple column classes on a div, I suggest an easy solution by adding justify-content-end
to the row enclosing the columns.
Here is an example:
<div class="row justify-content-end">
<div class="col-md-6 col-lg-4 col-xl-3">
First col text
</div>
<div class="col-md-6 col-lg-4 col-xl-3">
First col text
</div>
<div class="col-md-6 col-lg-4 col-xl-3">
Second col text
</div>
<div class="col-md-6 col-lg-4 col-xl-3">
Third col text
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With