Home > other >  How to align button on right in bootstrap
How to align button on right in bootstrap

Time:03-17

How to align button to left inside of a div which is having justify-content-center class applied. Code -

<div >
 <div>
 <div >
 Text in Center
 </div>
<div ><button>Button on right</button></div>
 </div>
</div>

float-right is not working because of justify-content-center I tried placing justify-content-center on a separate div, but the text not getting center.

Code-

<div >
  <div >
   <div >
    Text in Center
   </div>
  <div ><button>Button on right</button></div>
 </div>
</div>

This approach is not working. I am not sure why the text not getting in center if I put justify-content-center class on other div

CodePudding user response:

The justify-content-end only works on the parent tag. Have you tried using ml-auto instead ?

More info : https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content

CodePudding user response:

Please try this code:

<div >
 <div>
  <div >
   Text in Center
  </div>
  <div ><button>Button on right</button></div>
</div>
  • Related