Reputation: 21
I have used this code to create 4 columns in Bootstrap
<div id="col" class="container-fluid row">
<div class="col-md-3">
<center>
<h4>Our Story</h4><img src="box.png" />
</center>
</div>
<div class="col-md-3">
<h4>Our Story</h4><img src="box.png" />
</div>
<div class="col-md-3">
<h4>Our Story</h4><img src="box.png" />
</div>
<div class="col-md-3">
<h4>Our Story</h4><img src="box.png" />
</div>
</div>
now these columns are aligned horizontally on desktop screen but when I open in mobile then all columns gets align vertically on the left side so I want to make them align center, how can I achieve that?
Upvotes: 0
Views: 601
Reputation: 60563
This is so wrong in many ways:
don't use center
tag it is deprecated, use .text-center
from bootstrap instead
.row
must be child of .container
if you need to style for mobile you have to use class xs
See more info about bootstrap documentation
Because it is not clear what you are trying to achieve in your mobile view here 2 snippets:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="col" class="container-fluid">
<div class="row text-center">
<div class="col-xs-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
</div>
</div>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="col" class="container-fluid">
<div class="row text-center">
<div class="col-xs-12 col-sm-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-12 col-sm-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-12 col-sm-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
<div class="col-xs-12 col-sm-3">
<h4>Our Story</h4>
<img src="//placehold.it/100x100" />
</div>
</div>
</div>
Upvotes: 5