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

前端 未结 18 2347
猫巷女王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:27

    HTML:

    Left
    Center

    CSS:

     #container{width:98%; }
     #left{float:left;}
     #center{text-align:center;}
     #right{float:right;}
    

    text-align:center; gives perfect centre align.

    JSFiddle Demo

提交回复
热议问题