Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

How to align content of a div to the bottom using CSS ?

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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.Here are a few examples using these properties. 

Example:Button shift to the bottom left corner of the div element. 

html




<!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>
                

Output:

  

Example:Button shift to the bottom right corner of the div element. 

html




<!DOCTYPE html>
<!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
          

Output:

 

CSS is the foundation of webpages, is used for webpage development by styling websites and web apps. You can learn CSS from the ground up by following this CSS Tutorial and CSS Examples.


My Personal Notes arrow_drop_up
Last Updated : 30 Jun, 2022
Like Article
Save Article
Similar Reads
Related Tutorials