CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



bottom

CSS or Cascading Style Sheets is a style sheet language used for describing the presentation of a document written in HTML or XML. It is used to style web pages and make them visually appealing. One of the important concepts in CSS is the bottom property. In this article, we will discuss the bottom property in CSS, its usage, and code examples.

What is Bottom in CSS?

The bottom property in CSS is used to set the bottom position of an element. It specifies the distance between the bottom edge of an element and the bottom edge of its containing block. The containing block is the nearest positioned ancestor element or the initial containing block if there is no positioned ancestor element.

The bottom property is used with the position property. The position property specifies the type of positioning used for an element. There are four types of positioning in CSS: static, relative, absolute, and fixed. The bottom property is used with the relative, absolute, and fixed positioning types.

Usage of Bottom in CSS

The bottom property is used to position an element relative to its containing block. It is used to set the distance between the bottom edge of an element and the bottom edge of its containing block. The bottom property is used with the position property to specify the type of positioning used for an element.

The bottom property is used with the relative, absolute, and fixed positioning types. The relative positioning type positions an element relative to its normal position. The absolute positioning type positions an element relative to its nearest positioned ancestor element. The fixed positioning type positions an element relative to the viewport.

Code Examples

Here are some code examples of using the bottom property in CSS:

Example 1: Using Bottom with Relative Positioning

In this example, we will use the bottom property with the relative positioning type. The bottom property will set the distance between the bottom edge of the element and the bottom edge of its containing block.

    
        <div style="position: relative; bottom: 20px;">
            This is a div element with relative positioning and a bottom distance of 20px.
        </div>
    

Example 2: Using Bottom with Absolute Positioning

In this example, we will use the bottom property with the absolute positioning type. The bottom property will set the distance between the bottom edge of the element and the bottom edge of its nearest positioned ancestor element.

    
        <div style="position: relative;">
            <div style="position: absolute; bottom: 20px;">
                This is a div element with absolute positioning and a bottom distance of 20px.
            </div>
        </div>
    

Example 3: Using Bottom with Fixed Positioning

In this example, we will use the bottom property with the fixed positioning type. The bottom property will set the distance between the bottom edge of the element and the bottom edge of the viewport.

    
        <div style="position: fixed; bottom: 20px;">
            This is a div element with fixed positioning and a bottom distance of 20px.
        </div>
    

Conclusion

The bottom property in CSS is used to set the bottom position of an element. It specifies the distance between the bottom edge of an element and the bottom edge of its containing block. The containing block is the nearest positioned ancestor element or the initial containing block if there is no positioned ancestor element. The bottom property is used with the position property to specify the type of positioning used for an element. It is used with the relative, absolute, and fixed positioning types.

References

Activity