CSS 3 column liquid layout with fixed center column

后端 未结 4 1224
一个人的身影
一个人的身影 2021-02-04 12:09

I want to make for my marketing site a 3 column layout that has images in the top banner.

I want to have a liquid left/right side with a fixed center. The html would

4条回答
  •  不要未来只要你来
    2021-02-04 12:34

    Here's a good solution, in my opinion the easiest one. It looks clean and it doesn't need wrapper div.

    Demo

    HTML

    
    
    
    left content
    center content

    CSS

    #left_container {
      width:50%;
      float:left;
      margin-right:-480px; /* minus half of the center container width */
    
      /* not important */
      height: 200px;
    }
    #left {
      margin-right:480px; /* half of the center container width */
    
      /* not important */
      background: #888;
      height: 600px;
    }
    #center {
      width:960px; /* size of the fixed width */
      float:left;
    
      /* not important */
      color: #FFF;
      background: #333;
      height: 500px;
    }
    #right_container {
      width:50%;
      float:right;
      margin-left:-480px; /* minus half of the center container width */
    
      /* not important */
      height: 300px;
    }
    #right {
      margin-left:480px; /* half of the center container width */
    
      /* not important */
      height: 300px;
      background-color: #888;
    }
    

    enjoy!

提交回复
热议问题