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

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

    Float property is actually not used to align the text.

    This property is used to add element to either right or left or center.

    div > div { border: 1px solid black;}
    
         
    First
    Second
    Third
    First
    Second
    Third

    for float:left output will be [First][second][Third]

    for float:right output will be [Third][Second][First]

    That means float => left property will add your next element to left of previous one, Same case with right

    Also you have to Consider the width of parent element, if the sum of widths of child elements exceed the width of parent element then the next element will be added at next line

     
         
    First
    Second
    Third

    [First] [Second]

    [Third]

    So you need to Consider All these aspect to get the perfect result

提交回复
热议问题