![]() |
Alignment of elements can be done using different methods. To align one item to the right we can use justify-content: flex-end property and margin-left: auto property. This property aligns the flex items along the main axis, pushing them to the end of the container. Table of Content Using justify-content: flex-end PropertyThe container div contains two flex containers inside (.flex-container1 and .flex-container2). The flex container (flex-container1) has a justify-content value left whereas flex-container2 has a justify-content value flex-end. The property justify-content: flex-end to align items to the right within the flex container. Example: Illustration of alignment of the one item to the right using justify-content: flex-end Property. HTML
Output: Using margin-left: auto PropertyA centered flex layout with a container (flex-container) containing three flex items (flex-item). The first 2 items (item1 and item2) are aligned to the left the container. One of the flex items (Item 3) is aligned to the right within the container using the class .align-right, achieved by applying margin-left: auto. Example: Illustration of alignment of the one item to the right using CSS Flexbox using margin-left: auto Property. HTML
Output: |
Reffered: https://www.geeksforgeeks.org
CSS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |