Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align button to the right

I know this must be really simple but I'm trying to set a button to the right of the window using only bootstrap 4 classes. It must be in the same row as the text.

<html> <head> </head>     <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>     <body>         <div class="row">             <h3 class="one">Text</h3>             <button class="btn btn-secondary pull-right">Button</button>         </div>     </body> </html> 

The code is in here

like image 560
jecabeda Avatar asked Jan 27 '17 13:01

jecabeda


People also ask

How do you align a button to the right?

If you want to move the button to the right, you can also place the button within a <div> element and add the text-align property with its "right" value to the "align-right" class of the <div>.

How do you align buttons?

We can align the buttons horizontally as well as vertically. We can center the button by using the following methods: text-align: center - By setting the value of text-align property of parent div tag to the center. margin: auto - By setting the value of margin property to auto.

How do I fix the button on the right side in HTML?

Answer: Use the text-right Class You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.

How do you align a button to the right flex?

Approach #1: Use align-self: flex-end on the button. This would make the button appear in the rightmost corner of your parent. Approach #2: In case you want more control over the position of the button in terms of alignment with the text area, you can wrap the button in a div and keep the float right on the button.


1 Answers

Bootstrap 4 uses .float-right as opposed to .pull-right in Bootstrap 3. Also, don't forget to properly nest your rows with columns.

<div class="row">     <div class="col-lg-12">         <h3 class="one">Text</h3>         <button class="btn btn-secondary float-right">Button</button>     </div> </div> 
like image 99
Serg Chernata Avatar answered Nov 04 '22 16:11

Serg Chernata