Getting 2 divs on the same line

后端 未结 5 1888
梦如初夏
梦如初夏 2021-01-22 05:53

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

相关标签:
5条回答
  • 2021-01-22 06:01

    Add float : left; attribute to the div.menu

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

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

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

    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)
  • 2021-01-22 06:25
    #NavigationMenu {
        float: left;
    }
    
    .SearchBox {
        float: right;
    }
    
    .MenuDiv {
        overflow: hidden; /* adjusts the height of .MenuDiv to wrap its children */
    }
    
    0 讨论(0)
  • 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)
提交回复
热议问题