CSS controls the center of the navigation bar

Source: Internet
Author: User
css| Navigation | control

In the process of learning, I want to be able to get the CSS navigation bar can also center the effect
However, the use of ordinary text-align:center;
Does not work, after searching on the web
A link to the classic forum, the UK's Cssplay website published two ways to get it centered
One of them uses a very strange del tag and doesn't know why
But it's still nice to solve a problem.

#menu1 {  width:408px;  padding:0;   margin:0 Auto;   List-style-type:none;  } #menu1 li {  float:left;  width:100px;  border:1px solid #fff;   } #menu1 a {  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 a {  width:auto;  Display:block;  PADDING:4PX 16px;  Color: #fff;   Background: #08c;   border:1px solid #fff;   Text-decoration:none;  } * HTML #menu2 a {  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.