Div side by side without float

后端 未结 6 1216
自闭症患者
自闭症患者 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:53

    A div is a block level element, meaning that will behave as a block, and blocks can't stay side by side without being floated. You can however set them to inline elements with:

    display:inline-block;
    

    Give it a try...


    Another way is to place them using:

    position:absolute;
    left:0;
    

    and/or

    position:absolute;
    right:0;
    

    Note: For this to work as expected, the wrapper element must have a position:relative; so that the elements with absolute positioning stay relative to their wrapper element.

提交回复
热议问题