Div side by side without float

后端 未结 6 1201
自闭症患者
自闭症患者 2020-12-01 01:31

How can I make div \'left\' and \'right\' look like columns side by side?

I know I can use float:left on them and that will work... but on step 5 and 6 in here http

6条回答
  •  攒了一身酷
    2020-12-01 01:43

    The usual method when not using floats is to use display: inline-block: http://www.jsfiddle.net/zygnz/1/

    .container div {
      display: inline-block;
    }
    

    Do note its limitations though: There is a additional space after the first bloc - this is because the two blocks are now essentially inline elements, like a and em, so whitespace between the two counts. This could break your layout and/or not look nice, and I'd prefer not to strip out all whitespaces between characters for the sake of this working.

    Floats are also more flexible, in most cases.

提交回复
热议问题