How can I float a column to right of the all above columns which are contained inside the same row.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<div class="row content">
<div class="col-md-8 first-content">
Some content
</div>
<div class="col-md-8 second-content">
Some other content
</div>
<div class="col-md-4 float-right-top">
This content need to float left
</div>
</div>
5
Answers
Just add
position: absolute
,right: 0;
andtop: 0;
tofloat-right-top
class.HTML:
CSS:
Fiddle:
https://jsfiddle.net/8Lurbc78/
Try this
working fiddle : https://jsfiddle.net/qeu3t8gk/
The point is the class content which you used messed the css
In every bootstrap row you have 12 columns. Now look at the code. You have assigned 8 columns to the first content
class="col-md-8 first-content"
so12-8=4 Therefore, only 4 columns remain for you, and you have assigned these 4 columns to the third
div
. Notice, that by default float is left. And everything starts from left. Therefore it would be placed in the right hand side of therow
If you add extra space using margin between the divs then automatically it would be moved to the extra row in the below
so make sure for all dives you have
Here is the complete code
What is wrong with ur code too?
You have set 2
div
s withcol-8
in the same row. So, the browser calculates it as8+8=16
, and it understands also16>12
(12 is maximum columns which you can have in arow
). Therefore, it cannot afford it so it makes an extrarow
, and put your seconddiv
and allocate 8 columns to it in the second row.Please see the below image:
I’ve updated @StaXter answer.
create to parent div for left and right and place your content inside them.
HTML
CSS
How about nesting the rows? Fiddle here: https://jsfiddle.net/p3qrexxe/
HTML
CSS