Move boostrap column to the right

0

I do not want to move the content of the column, I want to move the column. I have these div each with a column.

<div id="menuV" class="col-md-1"></div>
<div id="cerrarSesion" class="col-md-11"></div>   

In a window the two divs are shown and everything fits well, but in another window only the column with size 11 is shown. This column would like me to move to the right side and not to the left as it remains by default.

I tried to do a col-md-offset-1 to the column of size 11 and when it appears alone it shows well (Glued to the right) but when the two columns are, then it is mounted one on top of the other

    
asked by Lorenzo Martín 25.05.2018 в 12:35
source

2 answers

2

Your problem is simple, the col-md-offset-1 , use it is the other div or is not, that is, that of the gaps that are available in a row will always move 1 position, this means, that if it occupies 11 of the 12 columns that use bootstrap, when it is not the div menu, it will work well, since the% co_of% of 11 columns can work on 12, the thing is that when the menu is, the% co_of% of 11 columns has only 11 columns for it, as soon as you make an offset-1, it will try to move a column to the right, at the end of the available space, it looks for the nearest possible position that is at the beginning of the next row .

Possible solution:

Check if the div menu exists or is visible (depends on you)

if($("#menuV").length>0 && $("#menuV").css("display")!="none" ){
    $("#cerrarSesion").addClass("col-md-offset-1");
}else{
    //para asegurarse
    $("#cerrarSesion").removeClass("col-md-offset-1");
}

I hope you have served:)

    
answered by 25.05.2018 / 12:57
source
2

For the topic of columns, rows and others you can take a look at Grid system - Bootstrap

If you want the two columns to stay on the right you can try "justify-content-end".

<div class="row justify-content-end">
  <div id="menuV" class="col-1"></div>
  <div id="cerrarSesion" class="col-11"></div>
</div>
    
answered by 25.05.2018 в 13:02