Center the css control navigation bar

Source: Internet
Author: User

In the course of learning, I hope that the css navigation bar can also be centered.
However, the common text-align: center;
Does not work. After searching on the Internet
Link to the classic Forum. Two methods to center cssplay are published on the uk website.
One of them uses a very strange del tag. I don't know why.
However, I am still very happy to solve this problem.

The code is as follows: Copy code
# Menu1 {
Width: 408px;
Padding: 0;
Margin: 0 auto;
List-style-type: none;
}
# Menu1 li {
Float: left;
Width: 100px;
Border: 1px solid # fff;
}
# Menu1 {
Display: block;
Width: 100px;
Color: #000;
Background: # d4d4d4;
Text-align: center;
Padding: 4px 0;
Text-decoration: none;
Float: left;
}
# Menu1 a: hover {
Color: # fff;
Background: # 08c;
}
# Menu2 {
Display: table;
Padding: 0;
Margin: 0 auto;
List-style-type: none;
White-space: nowrap;
}
# Menu2 li {
Display: table-cell;
}
* Html # menu2 li {
Float: left;
}
# Menu2 {
Width: auto;
Display: block;
Padding: 4px 16px;
Color: # fff;
Background: # 08c;
Border: 1px solid # fff;
Text-decoration: none;
}
* Html # menu2 {
Float: left;
}
# Menu2 a: hover {
Color: #000;
Background: # d4d4d4;
}
. Container {clear: both; text-decoration: none ;}
* Html. container {display: inline-block ;}
XHTML <ul id = "menu1">
<Li> <a href = "# nogo"> Tab One </a> </li>
<Li> <a href = "# nogo"> Tab Two </a> </li>
<Li> <a href = "# nogo"> Tab Three </a> </li>
<Li> <a href = "# nogo"> Tab Four </a> </li>
</Ul>
<Del class = "container">
<Ul id = "menu2">
<Li> <a href = "# nogo"> Tab One </a> </li>
<Li> <a href = "# nogo"> Tab Two: Longer </a> </li>
<Li> <a href = "# nogo"> Tab Three: Longest </a> </li>
<Li> <a href = "# nogo"> Tab Four </a> </li>
</Ul>
</Del>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.