简体   繁体   中英

Fixed width content with flexible (strechable) sidebar

Rather than trying to explain this - which would be hard I have created an image - I am having trouble creating a layout in which: The sidebar is flexible and can extend to fill the empty space not consumed by the content fiv which has a fixed width of 725px.

Have a look at the image please :) 在此输入图像描述

I'm thinking this is what you need: http://jsfiddle.net/Shaz/GaZYt/1/

Html:

<div id="contain">
    <div id="left">
        Left <br /> <br /> <br />
    </div>

    <div id="right">
        Right
    </div>
</div>

CSS:

#contain {
    width 100%;   
}

#contain #left {
    min-width: 185px;
    width: 100%;
    border: 1px solid blue;
    display: table-cell;
}

#contain #right {
    min-width: 725px;       
    border: 1px solid red;
    display: table-cell;
}

Little positioning witchcraft, seems to match your picture: right part has fixed width 200px, the left one takes the rest (but never smaller than 100px).

 #container { position: relative; min-width: 310px; } #container .left { background-color: blue; margin-right: 210px; height: 200px; } #container .content { float: right; background-color: green; width: 200px; height: 200px; position: absolute; top: 0; right: 0; } 
 <div id="container"> <div class="left">a</div> <div class="content">b</div> </div> 

Demo: http://jsfiddle.net/nzd2J/2/ . Move vertical splitting bar to see how it scales.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM