Open In App

CSS bottom Property

Discover the power of the CSS Bottom Property, a versatile tool that modifies an element’s vertical position. This property is instrumental in defining the distance of an element from the viewport’s bottom, offering precise control over your webpage layout.

Syntax:

bottom: auto| length| %| initial| inherit;

Property values: 

Methods to use CSS Bottom Property

1. Using bottom property value as auto:

Example: This example illustrates the use of the bottom property whose value is set to auto.

<!DOCTYPE html>
<html>
  
<head>
    <title> Bottom Property</title>
</head>

<body>
    <h1 style="color:darkgreen;">GeeksforGeeks</h1>
    <p style="position: fixed;
            bottom: auto;">
        This line will be auto adjusted for
        bottom based on the browser.
    </p>

</body>
  
</html>

Output:

2. Using bottom property value in pixels:

Example: This example illustrates the use of the bottom property where the property value is assigned as px.

<!DOCTYPE html>
<html>
  
<head>
    <title> Bottom Property</title>
</head>

<body>
    <h1 style="color:darkgreen;">GeeksforGeeks</h1>
    <p style="position: fixed; 
              bottom: 50px;">
        This line will be adjusted for bottom based
        on the length provided, i.e. 50px.
    </p>

    <p style="position: fixed; 
              bottom: -15px;">
        This line will be adjusted for bottom based
        on the length provided, i.e. -15px.
    </p>

</body>
  
</html>

Output:

3. Using bottom property value in Percentage:

Example: This example illustrates the use of the bottom property whose value is assigned as a percentage.

<!DOCTYPE html>
<html>
  
<head>
    <title> Bottom Property</title>
</head>

<body>
    <h1 style="color:darkgreen;">GeeksforGeeks</h1>
    <p style="position: 
              fixed; bottom: 10%;">
        This line will be adjusted for bottom based
        on the percentage provided, i.e. 10%.
    </p>

    <p style="position: 
              fixed; bottom: -5%;">
        This line will be adjusted for bottom based
        on the percentage provided, i.e. -5%.
    </p>

</body>
  
</html>

Output:

4. Using bottom property value initial:

Example: This example illustrates the use of the bottom property whose value is set to its default value.

<!DOCTYPE html>
<html>
  
<head>
    <title> Bottom </title>
</head>

<body>
    <h1 style="color:darkgreen;">GeeksforGeeks</h1>
    <p style="position: fixed;
              bottom: initial;">
        This line will be adjusted for bottom based
        on the initial value of the browser.
    </p>

</body>
  
</html>

Output:

5. Using bottom property value inherit:

Example: This example illustrates the use of the bottom property whose value is set to inherit.

<!DOCTYPE html>
<html>
  
<head>
    <title> Bottom </title>
</head>

<body>
    <h1 style="color:darkgreen;">GeeksforGeeks</h1>
    <p style="position: fixed; 
              bottom: inherit;">
        This line will inherit the position 
        from the parent element.
    </p>

</body>
  
</html>

Output:

Supported Browser:

Article Tags :