The alignment button at the bottom of the div using CSS

I want to align my button in the lower right corner of my div. How can i do this?

enter image description here

Current css div:

float: right; width: 83%; margin-right: 0px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; height:625px; overflow:auto; 
+65
css alignment button
Apr 28 2018-11-11T00:
source share
4 answers

You can use position:absolute; for absolute positioning of the element in the parent div. When using position:absolute; the element will be placed absolutely from the first positioned parent div, if it cannot find it, it will absolutely position from the window, so you will need to make sure that the contents of the div are located.

To position the contents of a div, all position values ​​that are not static will work, but relative is the easiest since it does not change the positioning of the divs by itself.

So add position:relative; in the content div, remove the float from the button and add the following css button to the button:

 position: absolute; right: 0; bottom: 0; 
+131
Apr 28 2018-11-11T00:
source share

CSS3 flexbox can also be used to align the button at the bottom of the parent element.

Required HTML:

 <div class="container"> <div class="btn-holder"> <button type="button">Click</button> </div> </div> 

CSS required:

 .container { justify-content: space-between; flex-direction: column; height: 100vh; display: flex; } .container .btn-holder { justify-content: flex-end; display: flex; } 

Screenshot:

Output image

Useful resources:

 * {box-sizing: border-box;} body { background: linear-gradient(orange, yellow); font: 14px/18px Arial, sans-serif; margin: 0; } .container { justify-content: space-between; flex-direction: column; height: 100vh; display: flex; padding: 10px; } .container .btn-holder { justify-content: flex-end; display: flex; } .container .btn-holder button { padding: 10px 25px; background: blue; font-size: 16px; border: none; color: #fff; } 
 <div class="container"> <p>Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... </p> <div class="btn-holder"> <button type="button">Click</button> </div> </div> 
+9
Mar 31 '17 at 16:04
source share

The parent container must have the following:

 position: relative; 

The button itself should have the following:

 position: relative; bottom: 20px; right: 20px; 

or what do you like

+7
Jan 04 '14 at 20:10
source share

Goes to the right and can be used in the same way for the left

 .yourComponent { float: right; bottom: 0; } 
-23
Nov 29 '12 at 2:11
source share



All Articles