Horizontally centering/evenly distributed
  • inside of
      inside a
  • 前端 未结 8 1702
    情书的邮戳
    情书的邮戳 2020-12-08 07:34

    Have a Navbar

    相关标签:
    8条回答
    • 2020-12-08 07:57

      Well ive try'd every thing, nothing is working so if you have the same problem, then i would recommend you use tables and td's to align them, still works properly.

      0 讨论(0)
    • 2020-12-08 08:00

      Basically comes down to add text-align: center to the ul and display: inline-block to the li's.

      This seems to do the trick:

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html>
      <head>
      <style type="text/css">
      .navbar {
          background-color: #ABCDEF;
      }
      .navbar ul {
          list-style-type: none;
          margin: 0px;
          padding: 0px;
          text-align: center;
      }
      .navbar li{
          display: inline-block;
          padding: 2px;
          width: 150px;
      }
      </style>
      </head>
      <body>
      <div class="navbar">
        <ul>
          <li><a href="Home">Home</a></li>
          <li><a href="Discounts">Discounts</a></li>
          <li><a href="Contact">Contact Us</a></li>
          <li><a href="About">About Us</a></li>
        </ul>
      </div>
      </body>
      </html>
      
      0 讨论(0)
    提交回复
    热议问题