Bootstrap columns do not work properly - html

Bootstrap rows and columns do not display properly on phones and other small devices.
Screenshot on mobile device
.
For tablets and bigger displays, this works properly.
Code
<div class="col-xs-5 col-sm-1"><i class="fa fa-mobile" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-3">ww</div>
<div class="col-xs-5 col-sm-1"><i class="fa fa-envelope-o" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-3">ww</div>
<div class="col-xs-5 col-sm-1"><i class="fa fa-map-marker" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-3">ww</div>
I made a temporary fix - I set the same height for these divs. But I don't think that will be always good solution.
After Temporary fix (align added on pic below)
How to resolve this problem in better way?

The problem stems from your floats not clearing. This is very common in Bootstrap layouts since almost all elements are floated and so they have included a helper class to deal with it.
<div class="clearfix">
You insert it in between items which would break to a new line in a specific breakpoint. So, in your case, after the first two "ww" divs for your xs breakpoint.
To only have it affect your xs breakpoint we add another Bootstrap helper class:
<div class="clearfix visible-xs">
More info on these helper classes can be found in the Bootstrap documentation:
Clearfix, Visibility Classes
Full example here:
i {
font-size: 30px !important;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-xs-5 col-sm-1"><i class="fa fa-mobile" aria-hidden="true"></i>
</div>
<div class="col-xs-7 col-sm-3">ww</div>
<div class="clearfix visible-xs"></div>
<div class="col-xs-5 col-sm-1"><i class="fa fa-envelope-o" aria-hidden="true"></i>
</div>
<div class="col-xs-7 col-sm-3">ww</div>
<div class="clearfix visible-xs"></div>
<div class="col-xs-5 col-sm-1"><i class="fa fa-map-marker" aria-hidden="true"></i>
</div>
<div class="col-xs-7 col-sm-3">ww</div>

To get proper benefit of bootstrap you should enclose each of 12 grid column in a row div. For example,
<div class="row">
<div class="col-xs-5 col-sm-5"><i class="fa fa-map-marker" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-7">ww</div>
</div>

You need to wrap each one of those column groups in 12 column rows. Your cols need to add up to 12 in each row for each breakpoint you add a class for. If you dont wrap them each in a row, they will auto wrap after 12 columns - but you need to make sure that the cols you want on the same row always adds up to 12.
ie.
<div class="row>
<div class="col-xs-7 col-sm-9">ww</div>
<div class="col-xs-5 col-sm-3"><i class="fa fa-mobile" aria-hidden="true"></i></div>
</div>
<div class="row>
<div class="col-xs-7 col-sm-9">ww</div>
<div class="col-xs-5 col-sm-3"><i class="fa fa-envelope-o" aria-hidden="true"></i></div>
</div>
<div class="row>
<div class="col-xs-7 col-sm-3">ww</div>
<div class="col-xs-5 col-sm-9"><i class="fa fa-map-marker" aria-hidden="true"></i></div>
</div>
This would also work with a bit less control of the layout (but you need to define ALL breakpoints - not just small and XS in your classes).
<div class="row>
<div class="col-xs-7 col-sm-9 col-md-9 col-lg-9">ww</div>
<div class="col-xs-5 col-sm-3 col-md-3 col-lg-3"><i class="fa fa-mobile" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-9 col-md-9 col-lg-9">ww</div>
<div class="col-xs-5 col-sm-3 col-md-3 col-lg-3"><i class="fa fa-envelope-o" aria-hidden="true"></i></div>
<div class="col-xs-7 col-sm-9 col-md-9 col-lg-9">ww</div>
<div class="col-xs-5 col-sm-3 col-md-3 col-lg-3"><i class="fa fa-map-marker" aria-hidden="true"></i></div>
</div>

Related

icons not placing side by side

I am new to bootstrap. I want to place 2 icons side by side on any screen size. It works properly on medium devices, but when I run it on mobile devices the icons are placed one below other and not side by side. Also, my margins are not working on smaller devices.
<div class="row text-center">
<div class="col-sm-6 xs-my-20 col-md-6">
<i class="fab fa-facebook-f icons"></i>
</div>
<div class="col-sm-6 xs-my-20 col-md-6">
<i class="fab fa-facebook-f icons"></i>
</div>
</div>
Simply use col-xs-6 like this:
<div class="container">
<div class="row text-center">
<div class="col-xs-6">
<i class="fab fa-facebook-f icons"></i>
</div>
<div class="col-xs-6">
<i class="fab fa-facebook-f icons"></i>
</div>
</div>
</div>
And if you upgrade to bootstrap V4 simply do this:
<div class="container">
<div class="row text-center">
<div class="col">
<i class="fab fa-facebook-f icons"></i>
</div>
<div class="col">
<i class="fab fa-facebook-f icons"></i>
</div>
</div>
</div>
I'm not sure if xs-my-20 is a custom class you have created but you should be able to add col-xs-6 and it will allow the two icons to be displayed side by side in any size screen.
if xs-my-20 is a custom class you may have some css that is affecting display such as margins etc.
You also don't need to add col-md-6. If you use col-xs-6 it will include xs and above (xs,sm,md,lg). as with all col sizes. for example col-md-6 already applies col-md-6 and col-lg-6 without you having to write it.
Hope this helped.
<div class="container">
<div class="row text-center">
<div class="col-xs-6">
<i class="fab fa-facebook-f icons"></i>
</div>
<div class="col-xs-6">
<i class="fab fa-facebook-f icons"></i>
</div>
</div>
</div>

Change format from one column to two columns

<div class="wrapper">
<div class="container">
<div class="blocks">
<h2 style="text-align: center">Extra Information</h2>
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-book fa-2x" aria-hidden="true"></i><br>Reference it for later</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-commenting-o fa-2x" aria-hidden="true"></i><br>Give Feedback</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-info fa-2x" aria-hidden="true"></i><br>Why are annotations so important?</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-magic fa-2x" aria-hidden="true"></i><br>They say Annotation websites are for genius; well this is why you are here!</div>
<br><br><br>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-exchange fa-2x" aria-hidden="true"></i><br>Interaction</div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"><i class="fa fa-question-circle fa-2x" aria-hidden="true"></i><br>Information</div>
</div>
</div>
</div>
</div>
It looks like Image 1
How can I make it look like image 2 but with 2 columns, because mine is all stuck with eachother:
First, you can't have more than 12 col by row, so your code is wrong.
Second, please, don't use the "I'll put every class and it'll work" as suggested by my fellow, Bootstrap work on a cascade way, you just have to set on the "until the smallest screen" you want.
If you want 2 col even in xs-, then just use the col-xs-6, no need to set the sm- / md- / lg-.
And last, I don't really understand what you want, this ?
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="wrapper">
<div class="container">
<div class="blocks">
<h2 style="text-align: center">Extra Information</h2>
<div class="row">
<div class="col-xs-6"><i class="fa fa-book fa-2x" aria-hidden="true"></i><br>Reference it for later</div>
<div class="col-xs-6"><i class="fa fa-commenting-o fa-2x" aria-hidden="true"></i><br>Give Feedback</div>
</div>
<div class="row">
<div class="col-xs-6"><i class="fa fa-info fa-2x" aria-hidden="true"></i><br>Why are annotations so important?</div>
<div class="col-xs-6"><i class="fa fa-magic fa-2x" aria-hidden="true"></i><br>They say Annotation websites are for genius; well this is why you are here!</div>
</div>
<div class="row">
<div class="col-xs-6"><i class="fa fa-exchange fa-2x" aria-hidden="true"></i><br>Interaction</div>
<div class="col-xs-6"><i class="fa fa-2x" aria-hidden="true"></i><br></div>
</div>
</div>
</div>
</div>
In bootstrap, .col-md- class is used for medium screens, .col-xs- means extra small and col-sm for small screens
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="wrapper">
<div class="container">
<div class="blocks">
<h2 style="text-align: center">Extra Information</h2>
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-6">
<i class="fa fa-book fa-2x" aria-hidden="true"></i><br>Reference it for later
<br>
<i class="fa fa-commenting-o fa-2x" aria-hidden="true"></i><br>Give Feedback
</div>
<div class="col-md-6 col-sm-6 col-xs-6">
<i class="fa fa-info fa-2x" aria-hidden="true"></i><br>Why are annotations so important?
<br>
<i class="fa fa-magic fa-2x" aria-hidden="true"></i><br>They say Annotation websites are for genius; well this is why you are here!
</div>
</div>
</div>
</div>
</div>

Center bootstrap row

I am using bootstrap list-group to display links to itunes, amazon and google play. Each link is its own list-group-item. I would like for all of these items to be centered inline with one another. How do I do this?
<!-- Download badges -->
<div class="container-fluid">
<div class="row">
<div class="list-group">
<div class="col-xs-4 col-sm-4 col-med-4 col-lg-2">
<a href="http://hyperurl.co/cplq6c" class="list-group-item" target="_blank">
<i class="fa fa-apple fa-2x" aria-hidden="true"></i>itunes</a>
</div>
<div class="col-xs-4 col-sm-4 col-med-4 col-lg-2">
<a href="http://hyperurl.co/1qcfl6" class="list-group-item" target="_blank">
<i class="fa fa-amazon fa-2x" aria-hidden="true"></i>amazon</a>
</div>
<div class="col-xs-4 col-sm-4 col-med-4 col-lg-2">
<a href="http://hyperurl.co/mb95g4" class="list-group-item" target="_blank">
<i class="fa fa-google fa-2x" aria-hidden="true"></i>google play</a>
</div>
</div>
</div>
</div>
To be more clear, I would like to have the list-group centered on the page.
Use the col-lg-offset-* classes. Demo. You need it on your first column.
<div class="col-xs-4 col-sm-4 col-med-4 col-lg-2 col-lg-offset-3">
...
</div>
Change
<div class="container-fluid">
to
<div class="container">

2 bootstrap button in 1 line on mobile

how to make two buttons in one line using the bootstrap in the mobile display ? i use this code, but in the mobile view it displays 2 line.
<div class="row" style="margin-top:50px">
<div class="col-md-12 col-centered">
<div class="col-md-3"></div>
<div class="col-md-3 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Izin</h3>
</div>
<div class="col-md-3 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Cuti</h3>
</div>
<div class="col-md-3"></div>
</div>
</div>
You have to add to your button divs the classes: col-xs-3 aswell to adjust it on mobile. On tablet views its col-sm-3
Check this Fiddle
For a full reference to breakpoints in bootstrap check:
Bootstrap Grid
You have to use the class col-sm-* in order to target small devices
Edit:
<div class="row" style="margin-top:50px">
<div class="col-md-12 col-sm-12 col-centered">
<div class="col-md-3 hidden-sm"></div>
<div class="col-md-3 col-sm-6 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Izin</h3>
</div>
<div class="col-md-3 col-sm-6 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Cuti</h3>
</div>
<div class="col-md-3 hidden-sm"></div>
</div>
</div>
I edited wlalele's answer a little. The changes required here is adding extra class(col-xs-3) for smaller mobile device screens.
<div class="row" style="margin-top:50px">
<div class="col-md-12 col-sm-12 col-centered">
<div class="col-md-3 hidden-sm col-xs-3"></div>
<div class="col-md-3 col-sm-6 col-xs-3 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Izin</h3>
</div>
<div class="col-md-3 col-sm-6 col-xs-3 text-center">
<i class="fa fa-file-text-o"></i><br/>
<h3>Ajukan Cuti</h3>
</div>
<div class="col-md-3 hidden-sm col-xs-3"></div>
</div>
</div>

Bootstrap columns inside panel

I am trying to create 3 columns inside a panel but for some reason the xs viewport does not look right. The last column moves below the row. You can see it on this jsfiddle.
Any clues what I might be doing wrong?
<div class="container">
<div class="row">
<div class="col-xs-12">
<div class="panel panel-default content-parent">
<div class="panel-header content-header">
<div class="row content-header-assets">
<div class="col-xs-1">
<i class="fa fa-angle-left content-header-actions"></i>
</div>
<div class="col-xs-10">
<h1 class="content-header-title text-center">Some long text</h1>
</div>
<div class="col-xs-1">
<i class="fa fa-angle-right content-header-actions"></i>
</div>
</div>
</div>
<div class="panel-body">
<div class="content-body col-xs-12 col-sm-10 col-md-9 col-lg-7 block-center">
</div>
</div>
<div class="panel-footer content-footer text-center">
</div>
</div>
</div>
</div>
</div>
.col-*-1 is 8.33333333% of the space provided, so your content (the .fa .fa-angle-right/left) doesn't fit since it's larger than 8.333%. This is not the best solution for this type of layout, but you can try .col-xs-2 on the left and right and .col-xs-8 on the middle.