How to get these two divs side-by-side?

前端 未结 8 955
無奈伤痛
無奈伤痛 2020-11-27 14:28

I have two divs that are not nested, one below the other. They are both within one parent div, and this parent div repeats itself. So essentially:

8条回答
  •  广开言路
    2020-11-27 15:24

    Since div's by default are block elements - meaning they will occupy full available width, try using -

    display:inline-block;
    

    The div is now rendered inline i.e. does not disrupt flow of elements, but will still be treated as a block element.

    I find this technique easier than wrestling with floats.

    See this tutorial for more - http://learnlayout.com/inline-block.html. I would recommend even the previous articles that lead up to that one. (No, I did not write it)

提交回复
热议问题