How to align content of a div to the bottom using CSS ?
Basic property of CSS:
- position: The position property specifies the type of positioning method used for an elements. For example static, relative, absolute and fixed.
- bottom: The bottom property affects the vertical position of a positioned element. This property has no effect on non-positioned elements.
- left: The left property affects the horizontal position of a positioned element. This property has no effect on non-positioned elements.
- right: The right property affects the horizontal position of a positioned element. This property has no effect on non-positioned elements.
On the basic of the value of position property the value of the other property is set.
Example: In this code, use of these three properties is shown and button shift to the bottom left corner of the div element.
<!DOCTYPE html> <html> <head> <title>align content to div</title> <style> .main { border: 1px solid green; float: left; min-height: 180px; margin: 2px; padding: 10px; min-width: 117px; position:relative; } .gfg { font-size:40px; color:green; font-weight:bold; tect-align:center } .geeks { text-align:center; } #bottom { position:absolute; bottom:0; left:0; } </style> </head> <body> <div class="main"> <div class = "gfg">GeeksforGeeks</div> <div class = "geeks">A computer science portal for geeks</div> <div id="bottom">Bottom Content Div</div> </div> </body> </html> |
chevron_right
filter_none
Output:

Example: In this code, below use of this three property is shown and button shift to the bottom right corner of the div element.
<!DOCTYPE html> <html> <head> <title>align content to div</title> <style> .main { border: 1px solid green; float: left; min-height: 180px; margin: 2px; padding: 10px; min-width: 117px; position:relative; } .gfg { font-size:40px; color:green; font-weight:bold; tect-align:center } .geeks { text-align:center; } #bottom { position:absolute; bottom:0; right:0; } </style> </head> <body> <div class="main"> <div class = "gfg">GeeksforGeeks</div> <div class = "geeks">A computer science portal for geeks</div> <div id="bottom">Bottom Content Div</div> </div> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- CSS | align-content property
- How to use Bootstrap to align labels with content into 4 columns ?
- How to Align modal content box to center of any screen?
- CSS | Align
- CSS | align-self Property
- HTML | <img> align Attribute
- HTML | DOM Div align Property
- CSS | vertical-align Property
- HTML | <h1> to <h6> align Attribute
- HTML | <tr> align Attribute
- HTML | <th> align Attribute
- CSS | align-items Property
- HTML | <td> align Attribute
- HTML | DOM HR align Property
- HTML | <p> align Attribute
- HTML | <hr> align Attribute
- HTML | <div> align Attribute
- CSS | text-align Property
- CSS | text-align-last Property
- HTML | <col> align Attribute
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


