![]() |
The navigation bar is a crucial aspect of modern web design. We can create a responsive navigation bar using CSS Flexbox, which provides a flexible and efficient way to layout elements, making it an excellent choice for creating navigation bars. Below are different possible ways for creating different types of Navbar: Table of Content Basic Horizontal Navigation BarUsing this approach we can create a straightforward horizontal navigation bar where all the links are laid out in a row. Flexbox makes it easy to distribute the space between the links evenly. These are used for simple websites where a basic, horizontal navigation is required without any complex alignment. Syntax:.navbar { Example: This demonstrates a basic horizontal navigation bar using HTML , CSS , featuring links to home, Services and Contact sections, styled with a dark background and white text.
Output: ![]() Basic Horizontal Navigation Bar Centered Navigation LinksThis approach centers the navigation links within the navigation bar. By using the justify-content: center property, we can align the links to the center of the container. It is used for websites where we want to focus the user’s attention on the navigation links by placing them in the center of the page. Syntax:.navbar { Example: This demonstrates a basic centered navigation bar using HTML , CSS , featuring links to home, Services and Contact sections, styled with a dark background and white text.
Output: ![]() Centered Navigation Links Right-Aligned Navigation LinksIn this approach, the navigation links are aligned to the right side of the navigation bar. By applying margin-left: auto to the last link or a wrapping div, the links move to the right. These are generally used in corporate or professional websites where a right-aligned navigation bar is preferred for a clean, organized look. Syntax:.navbar { Example: This demonstrates a basic right aligned navigation bar using HTML , CSS , featuring links to home, Services and Contact sections, styled with a dark background and white text.
Output: ![]() Right-Aligned Navigation Links Vertical Navigation BarA vertical navigation bar is created by changing the direction of the flex container to column. This arranges the links vertically instead of horizontally. It is ideal for sidebars or navigation menus that require vertical alignment, such as in dashboards or admin panels. Syntax:.navbar { Example: This demonstrates a basic left aligned navigation bar using HTML , CSS , featuring links to home, Services and Contact sections, styled with a dark background and white text.
Output: ![]() Vertical Navigation Bar Responsive Navigation BarThis approach ensures the navigation bar is compatible to different screen sizes. By using media queries, we can change the layout of the navbar based on the screen width, ensuring a good user experience on both desktop and mobile devices. These are important for modern websites that need to be accessible and functional on a variety of devices and screen sizes. Syntax:.navbar { Example: This demonstrates a responsive navigation bar using HTML , CSS , featuring links to home, Services and Contact sections, styled with a dark background and white text.
Output: |
Reffered: https://www.geeksforgeeks.org
CSS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 55 |