📅  最后修改于: 2023-12-03 14:40:16.959000             🧑  作者: Mango
As a programmer, you may have encountered the need to add a navigation menu to your website. This is a common feature on most websites, including Stack Overflow.
To create a navigation menu using CSS on Stack Overflow, you can follow these steps:
<ul>
) with list items (<li>
) for each navigation link. Give each list item an id
or class
to help with styling.<ul>
<li id="home"><a href="#">Home</a></li>
<li id="about"><a href="#">About</a></li>
<li id="contact"><a href="#">Contact</a></li>
</ul>
display: flex
to create a horizontal menu, justify-content: space-between
to space out the menu items evenly, and align-items: center
to align the items vertically.ul {
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 0 10px;
}
a {
color: #fff;
text-decoration: none;
}
#home {
background-color: #0077cc;
}
#about {
background-color: #009e60;
}
#contact {
background-color: #d55e00;
}
:hover
.li:hover {
background-color: #fff;
}
li:hover a {
color: #000;
}
This will create a simple and stylish horizontal navigation menu on Stack Overflow.
Note: The CSS styles used in this example are just for illustration purposes. You can customize them to suit your needs.
# CSS for Navigation Menu on Stack Overflow
As a programmer, you may have encountered the need to add a navigation menu to your website. This is a common feature on most websites, including [Stack Overflow](https://stackoverflow.com/).
To create a navigation menu using CSS on Stack Overflow, you can follow these steps:
1. Create a HTML unordered list (`<ul>`) with list items (`<li>`) for each navigation link. Give each list item an `id` or `class` to help with styling.
```html
<ul>
<li id="home"><a href="#">Home</a></li>
<li id="about"><a href="#">About</a></li>
<li id="contact"><a href="#">Contact</a></li>
</ul>
display: flex
to create a horizontal menu, justify-content: space-between
to space out the menu items evenly, and align-items: center
to align the items vertically.ul {
display: flex;
justify-content: space-between;
align-items: center;
list-style: none;
margin: 0;
padding: 0;
}
li {
margin: 0 10px;
}
a {
color: #fff;
text-decoration: none;
}
#home {
background-color: #0077cc;
}
#about {
background-color: #009e60;
}
#contact {
background-color: #d55e00;
}
:hover
.li:hover {
background-color: #fff;
}
li:hover a {
color: #000;
}
This will create a simple and stylish horizontal navigation menu on Stack Overflow.
Note: The CSS styles used in this example are just for illustration purposes. You can customize them to suit your needs.