How to position three divs in html horizontally?

前端 未结 4 2250
夕颜
夕颜 2020-12-13 12:20

I am creating a sample website which has three divisions horizontally. I want the left most div to be 25% width, the middle one to be 50% width, and right to be 25% width so

4条回答
  •  死守一世寂寞
    2020-12-13 12:35

    I know this is a very old question. Just posting this here as I solved this problem using FlexBox. Here is the solution

    #container {
      height: 100%;
      width: 100%;
      display: flex;
    }
    #leftThing {
      width: 25%;
      background-color: blue;
    }
    #content {
      width: 50%;
      background-color: green;
    }
    #rightThing {
      width: 25%;
      background-color: yellow;
    }
    Left Side Menu
    Random Content
    Right Side Menu

    Just had to add display:flex to the container! No floats required.

提交回复
热议问题