Two divs side by side - Fluid display

后端 未结 8 983
你的背包
你的背包 2020-11-22 03:09

I am trying to place two divs side by side and using the following CSS for it.

#left {
  float: left;
  width: 65%;
          


        
8条回答
  •  伪装坚强ぢ
    2020-11-22 03:42

    Try a system like this instead:

    .container {
      width: 80%;
      height: 200px;
      background: aqua;
      margin: auto;
      padding: 10px;
    }
    
    .one {
      width: 15%;
      height: 200px;
      background: red;
      float: left;
    }
    
    .two {
      margin-left: 15%;
      height: 200px;
      background: black;
    }

    You only need to float one div if you use margin-left on the other equal to the first div's width. This will work no matter what the zoom and will not have sub-pixel problems.

提交回复
热议问题