How to horizontally align a ul element to center

后端 未结 3 800
说谎
说谎 2021-01-25 02:49

I\'m not able to align a menu, contained within a ul, to the horizontal center of its container. how to do that?

See a live demo of the menu on jsFiddle.

3条回答
  •  伪装坚强ぢ
    2021-01-25 03:21

    Change the margin on the

      to 0 auto and give it a width (~575px or larger).

      jsFiddle example

       ul {
           font-family: Arial, Verdana;
           font-size: 14px;
           margin: 0 auto;
           padding: 0;
           width:600px;
           list-style: none;
           text-align: center;
       }
      

提交回复
热议问题