Display Two
s Side-by-Side

前端 未结 3 931
忘掉有多难
忘掉有多难 2020-12-08 06:50

My goal is to display two

s side-by-side with the content from both
s aligned at the top. I do not want long text in the seco
3条回答
  •  悲哀的现实
    2020-12-08 07:34

    Try this : (http://jsfiddle.net/TpqVx/)

    .left-div {
        float: left;
        width: 100px;
        /*height: 20px;*/
        margin-right: 8px;
        background-color: linen;
    }
    .right-div {
    
        margin-left: 108px;
        background-color: lime;
    }​​
    

     
    My requirements are [A] Content in the two divs should line up at the top, [B] Long text in right-div should not wrap underneath left-div, and [C] I do not want to specify a width of right-div. I don't want to set the width of right-div because this markup needs to work within different widths.
     

    Hints :

    • Just use float:left in your left-most div only.
    • No real reason to use height, but anyway...
    • Good practice to use
       
      after your last div.

提交回复
热议问题