How to make a page with header and left-sidebar?

后端 未结 6 886
醉话见心
醉话见心 2020-12-29 06:41

I\'d like to make a webpage like this:

|----------------------------|
|            header          |
|----------------------------|
|  L  |                           


        
相关标签:
6条回答
  • 2020-12-29 07:22

    Demo : http://jsfiddle.net/nRQeA/

    .top {
        width: 100%;
        height: 92px;
    
    }
    .left {
        width: 20%;
        height: 100%;
        float:left;
    }
    .main {
        float: left;
        height: 100%;
        width: 80%
    
     }
    
    0 讨论(0)
  • 2020-12-29 07:28

    You can also use display : table and display : table-cell to create a page that holds a table-level element with 2 table-cells (sidebar & content area)

    <div id="outer-container">
        <div id="sidebar"></div>
        <div id="content"></div>
    </div>
    
    #outer-container {
        display: table;
        width: 100%;
        height: 100%;
    }
    
    #sidebar {
        display: table-cell;
        width: 15%;
        vertical-align: top;
    }
    
    #content {
        display: table-cell;
        width: 85%;
        vertical-align: top;
    }
    

    A tutorial with a demo here : http://usefulangle.com/post/61/html-page-with-left-sidebar-main-content-with-css

    0 讨论(0)
  • 2020-12-29 07:35

    You just need to remove "float: left;" from your .main definition.

    Also, when debugging positioning this really helps:

    div {
        border: 1px solid #000;
    }
    

    Also it might be worth dropping height: 100% from .left and .main to prevent vertical scrollbar

    0 讨论(0)
  • 2020-12-29 07:37

    Here is the simple code for you. Try this & know the quality CSS coding.

    HTML:

    <div class="main">
    <div class="top">TOP</div>
    <div class="left">LEFT</div>
    <div class="right">MAIN</div>
    <div class="clear"></div>
    </div>
    

    CSS:

    .clear{
    clear:both;
    } 
    .main{
    width:500px;
    }
    .top {
    background: blue;
    width:500px;
    height: 92px;
    }
    .left {
    float:left;
    width: 150px;
    background: red;
    }
    .right{
    float:right;
    width:350px;
    background: yellow;
    }
    
    0 讨论(0)
  • 2020-12-29 07:39

    LIve demo

    Hi now you just do easily as like this

    Css

    .top {
        height: 92px;
    }
    .left {
        width: 178px;
        float:left;
    }
    .main {
      margin-left:178px;
     }
    

    HTML

    <div class="top">
        TOP
    </div>
    <div class="left">
        LEFT
    </div>
    <div class="main">
    N content here MAIN content here MAIN content here </div>
    

    Live demo

    ------------

    Updated Demo

    0 讨论(0)
  • 2020-12-29 07:41

    example at jsFiddle

    .top {
        position:absolute;
        left:0; right:0;
        height: 92px;
    }
    .left {
        position:absolute;
        left:0; top:92px; bottom: 0;
        width: 178px;
    }
    .main {
        position: absolute;
        left:178px; top:92px; right:0; bottom:0;
    }
    
    0 讨论(0)
提交回复
热议问题