开发者

Fixed width content with flexible (strechable) sidebar

开发者 https://www.devze.com 2023-02-14 23:29 出处:网络
Rather than trying to explain this - which would be hard I have created an image - I开发者_JS百科 am having trouble creating a layout in which:

Rather than trying to explain this - which would be hard I have created an image - I开发者_JS百科 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 :)

Fixed width content with flexible (strechable) sidebar


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消