Getting 2 divs on the same line

后端 未结 5 1482
离开以前
离开以前 2021-01-22 05:29

I\'m trying to get 2 divs on the same line, I\'ve got

相关标签:
5条回答
  • 2021-01-22 06:03
    #NavigationMenu {
        float: left;
    }
    
    .SearchBox {
        float: right;
    }
    
    .MenuDiv {
        overflow: hidden; /* adjusts the height of .MenuDiv to wrap its children */
    }
    
    0 讨论(0)
  • 2021-01-22 06:06

    line-height(child-elements) with a combination of the previous answers

    0 讨论(0)
  • 2021-01-22 06:07

    Set

    display: inline-block;

    And then set their widths as you need (as an absolute value or percentages of the parent container)

    Live Demo

    0 讨论(0)
  • 2021-01-22 06:09

    Add float : left; attribute to the div.menu

    0 讨论(0)
  • 2021-01-22 06:09

    You can play with float:

    float: left;
    float: right;
    clear: both;
    

    This is not always easy to do.

    Another option is to use

    display: inline-block;
    

    or to use a span.

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