How To Align Content Of Div To The Bottom using Css

admin_img Posted By Bajarangi soft , Posted On 08-10-2020

Use the text-align property to align the inner content of the block element. Use the bottom and left properties. The bottom property specifies the bottom position of an element along with the position property. The left property specifies the left position of an element along with the position property.

Align Content Of Div

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 #d5a44f;
            float: left;
            min-height: 180px;
            margin: 2px;
            padding: 10px;
            min-width: 117px;
            position:relative;
        }
        .gfg {
            font-size:40px;
            color: #e53922;
            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">Bajarangi Soft</div>
    <div class = "geeks">A web designing portal </div>
    <div id="bottom">Bottom Content Div</div>
</div>
</body>
</html>
Example:
 In this code, below use of this three property is shown and button shift to the bottom right corner of the div element.
br><!DOCTYPE html>
<html>
<head>
    <title>align content to div</title>
    <style>
        .main {
            border: 1px solid #ff302a;
            float: left;
            min-height: 180px;
            margin: 2px;
            padding: 10px;
            min-width: 117px;
            position:relative;
        }
        .gfg {
            font-size:40px;
            color: #dcb00d;
            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">Bajarangi Soft</div>
    <div class = "geeks">A computer science portal </div>
    <div id="bottom">Bottom Content Div</div>
</div>
</body>
</html>

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.

Related Post