Aligning
  • next to each other, not working
  • 前端 未结 4 860
    眼角桃花
    眼角桃花 2021-01-04 22:01

    I have a problem with aligment of two li elements inside a div because in the next example

    HTML

    相关标签:
    4条回答
    • 2021-01-04 22:09

      This is purely to do with the fact that your width specification is more than you've allowed for the child element in relation to it's parent elements:

      .menu-left ul li {
          display:inline-block;
          vertical-align: top;
          width: 50%; // should be less than 50%
      }
      

      Updated fiddle: http://jsfiddle.net/KhLhR/3/

      0 讨论(0)
    • 2021-01-04 22:12

      Add:

      float: Left;
      

      to the css class of the li elements of the menu (in this rule):

      ".menu-left ul li {"

      After the "width: 50%"

      The float property specifies whether or not a box (an element) should float. See http://www.w3schools.com/cssref/pr_class_float.asp

      0 讨论(0)
    • 2021-01-04 22:18

      Add a left float to your li elements:

      .menu-left ul li {
          display:inline-block;
          vertical-align: top;
          width: 50%;
          float: left;
      }
      
      0 讨论(0)
    • 2021-01-04 22:27

      http://jsfiddle.net/Soldier/KhLhR/1/

      .menu-left ul li {
          display:inline-block;
          float:left;
          vertical-align: top;
          width: 50%;
      }
      
      0 讨论(0)
    提交回复
    热议问题