How to position two divs horizontally within another div

前端 未结 13 1022
悲哀的现实
悲哀的现实 2020-12-12 11:12

I haven\'t played with CSS for too long a time and am without references at the moment. My question should be fairly easy but googling isn\'t bringing up a sufficient answer

13条回答
  •  清歌不尽
    2020-12-12 11:25

    When you float sub-left and sub-right they no longer take up any space within sub-title. You need to add another div with style = "clear: both" beneath them to expand the containing div or they appear below it.

    HTML:

    sub-left
    sub-right

    CSS:

    #sub-left {
       float: left;
    }
    #sub-right {
       float: right;
    }
    .clear-both {
       clear: both;
    }
    

提交回复
热议问题