Bootstrap 3 to Bootstrap 4 Cols No Longer Horizontally Aligned

bootstrap 3 to bootstrap 4 cols no longer horizontally aligned

Remove the col-12 as Bootstrap 4 requires a new row for columns to be nested.

https://getbootstrap.com/docs/4.0/layout/grid/#nesting

Columns won't horizontally align with Bootstrap

first of all, you need <div class = "row"> for every row of content you want to insert. That could be messing up your layout.

Example from your code:

<div class = "row">
<div class="col-xs-12 col-sm-12 col-lg-6">
<img src="./profile.jpg">
</div>
</div>

and so on.

Bootstrap 4: col-auto but not horizontally aligned

I think you should try to give a fixed width rather than using col-auto.
The fixed width will horizontally align all the columns. As you wanted 6 columns in a row then you can use col-md-2/col-sm-2/col-lg-2

<div class="container">
<div class="row">
<?php foreach($this->listEquations as $eq) { ?>
<div class="col-md-2">
<p class="title"><?php echo $eq->name; ?></p>
<p class="value"><?php echo $eq->value; ?></p>
</div>
<?php } ?>
</div>
</div>

Bootstrap cols are not next to each other

You have nested the columns, please read the docs about bootstrap. To achieve your scope try this code:

<div class='row'>
<div class="col-6">
</div>
<div class="col-2">
FOO
</div>
<div class="col-4">
BAR
</div>
</div>

Center a column using Twitter Bootstrap 3

There are two approaches to centering a column <div> in Bootstrap 3:

Approach 1 (offsets):

The first approach uses Bootstrap's own offset classes so it requires no change in markup and no extra CSS. The key is to set an offset equal to half of the remaining size of the row. So for example, a column of size 2 would be centered by adding an offset of 5, that's (12-2)/2.

In markup this would look like:

<div class="row">
<div class="col-md-2 col-md-offset-5"></div>
</div>

Now, there's an obvious drawback for this method. It only works for even column sizes, so only .col-X-2, .col-X-4, col-X-6, col-X-8, and col-X-10 are supported.


Approach 2 (the old margin:auto)

You can center any column size by using the proven margin: 0 auto; technique. You just need to take care of the floating that is added by Bootstrap's grid system. I recommend defining a custom CSS class like the following:

.col-centered{
float: none;
margin: 0 auto;
}

Now you can add it to any column size at any screen size, and it will work seamlessly with Bootstrap's responsive layout:

<div class="row">
<div class="col-lg-1 col-centered"></div>
</div>

Note: With both techniques you could skip the .row element and have the column centered inside a .container, but you would notice a minimal difference in the actual column size because of the padding in the container class.


Update:

Since v3.0.1 Bootstrap has a built-in class named center-block that uses margin: 0 auto, but is missing float:none, you can add that to your CSS to make it work with the grid system.

Bootstrap 4 col-sm-6 inside col-sm-6 not working

Bootrap 4 use "flex" styles. So you have two way:

1) You need to add

<div class="row">

before your first two divs with class col-sm-6 and close it after.

You can see your modified example: https://codepen.io/anon/pen/ZZPOEz

2) You need to add flex (display: flex;) to you first div on cols-sm-6, that contain two divs.

<div class="col-sm-6" style="display: flex;background-color:yellow;">

You can see your modified example: https://codepen.io/anon/pen/MRxeow

or add class 'row' to it - https://codepen.io/anon/pen/wZOWPO

<div class="col-sm-6 row" style="background-color:yellow;">

Bootstrap 4 - Nested columns - Fitting 4 columns inside col-11

I'm pretty sure you just need a row inside your col-11:

<div class="col-11 no-gutters">
<div class="row">
<div class="col-3 col-md-3 col-sm-3 col-lg-3">DISCOVER</div>
<div class="col-3 col-md-3 col-sm-3 col-lg-3">DESIGN</div>
<div class="col-3 col-md-3 col-sm-3 col-lg-3">DELIVER</div>
<div class="col-3 col-md-3 col-sm-3 col-lg-3">DEPLOY</div>
</div>
</div>

https://codepen.io/anon/pen/MPrQVa



Related Topics



Leave a reply



Submit