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

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

    possible answer, if you want to keep the order of the html and not use flex.

    HTML

    the
    jai ho
    watsup

    CSS

    .a {
      width: 500px;
      margin: 0 auto;
      border: 1px solid red;
      position: relative;
      display: table;
    }
    
    .c {
      display: table-cell;
      width:33%;
    }
    
    .d {
      text-align: right;
    }
    
    .e {
      position: absolute;
      left: 50%;
      display: inline;
      width: auto;
      transform: translateX(-50%);
    }
    

    Code Pen Link

提交回复
热议问题