3 columns, center column fixed, sides fill parents

后端 未结 3 1068
南旧
南旧 2020-12-01 23:05

How can I make B be a fixed 800px size while A and C fill the space, so they are all together touching? http://jsfiddle.net/8ufuV/

相关标签:
3条回答
  • 2020-12-01 23:15

    Fixed it up for you http://jsfiddle.net/8ufuV/17/ You need to float all the elements left; and then specific a width (don't forget about padding/margins when doing so). On an element you want to appear below them add clear:left; to it.

    Good luck

    0 讨论(0)
  • 2020-12-01 23:20

    HTML:

    <div id="main">
    
    <div id="leftblock">a</div>
    
    <div id="contentblock">b</div>
    
    <div id="rightblock">c</div>
    
    </div>
    

    CSS:

    #main {
      display:table;
      width:100%
    }
    
    div {
      display: table-cell
    }
    
    #leftblock{
      top: 0px;
      left: 0px;
      margin: 0px;
      padding: 10px;
      border: 5px solid #ccc;
      voice-family: "\"}\"";
      voice-family:inherit;
    }
    
    #contentblock{
      padding: 10px;
      border: 5px solid #ccc;
      width: 100px;
    }
    
    
    #rightblock{
      top: 0px;
      right: 0px;
      margin: 0px;
      padding: 10px;
      border: 5px solid #ccc;
      voice-family: "\"}\"";
      voice-family:inherit;
    }
    
    0 讨论(0)
  • 2020-12-01 23:34

    The easiest method is to use display: table-cell.

    See: http://jsfiddle.net/47d4f/

    That solves your problem, and also gives you equal height columns when the content is different in each column - something that isn't otherwise simple to obtain.

    Browser support: http://caniuse.com/css-table

    0 讨论(0)
提交回复
热议问题