How to align 3 divs (left/center/right) inside another div?

前端 未结 18 2346
猫巷女王i
猫巷女王i 2020-11-21 20:48

I want to have 3 divs aligned inside a container div, something like this:

[[LEFT]       [CENTER]        [RIGHT]]

Container div is 100% wid

18条回答
  •  情书的邮戳
    2020-11-21 21:10

    With that CSS, put your divs like so (floats first):

    P.S. You could also float right, then left, then center. The important thing is that the floats come before the "main" center section.

    P.P.S. You often want last inside #container this snippet:

    which will extend #container vertically to contain both side floats instead of taking its height only from #center and possibly allowing the sides to protrude out the bottom.

提交回复
热议问题