Horizontally align LI

后端 未结 1 1541
醉梦人生
醉梦人生 2021-01-23 03:05

I\'ve got 5 li on my page.

One of theme (the third) is higher than the other. I would like them to horizontally align to the center of this biggest LI. However, it\'s a

1条回答
  •  别那么骄傲
    2021-01-23 03:44

    #menu ul {
      margin: 0;
      padding: 0;
      list-style-type: none;
      text-align: center;
      width: 700px;
      /* some fixed width so, menu doesn't fall on next line*/
    }
    #menu li {
      /*  float: left; you can't align a floated element easily */
      margin: auto;
      padding: 0;
      background-color: black;
      display: inline-block;
      vertical-align: middle;
    }
    #menu li a {
      display: block;
      width: 100px;
      color: white;
      text-decoration: none;
    }
    #menu li a:hover {
      color: #FFD700;
    }
    #menu ul li ul {
      display: none;
    }
    #menu ul li:hover ul {
      display: block;
    }
    #menu li:hover ul li {
      float: none;
    }
    #menu li ul {
      position: absolute;
    }
    #menu {
      height: 30px;
    }
    /* Logo */
    
    #logo {
      height: 190px;
      width: 266px;
      background-color: black;
    }

    If i got your question correct, then this is what you need to do. I have just made the required changes, rest of code is all yours.

    0 讨论(0)
提交回复
热议问题