How to centrally align a float: left ul/li navigation menu with css?

后端 未结 10 1149
深忆病人
深忆病人 2020-12-28 14:57

So I have the following CSS in place to display a horizontal navigation bar using:

.navigation ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.naviga         


        
10条回答
  •  独厮守ぢ
    2020-12-28 15:15

    Well, to use margin:0 auto on something, it must have a defined width. Probably the best workaround is:

    ul li {
      display: inline;
      list-style-type: none;
    }
    ul {
      text-align:center;
    }
    

提交回复
热议问题