Half fixed, half scrollable layout that can be scrolled… CSS

前端 未结 3 2327
清歌不尽
清歌不尽 2020-12-31 07:50

I have an exotic design that needs the following. The left side must scroll, while the right side + top head must stay put (fixed). See attached image.

I can accompl

3条回答
  •  轮回少年
    2020-12-31 08:33

    Its not very hard to create a layout like this.

    I created one for you, see that Working Fiddle

    HTML:

    The Header div height is not fixed (But he can be if you want it to)

    This Layout has been tested on: IE10, IE9, IE8, FireFox, Chrome, Safari, Opera. using Pure CSS 2.1 only

    You can fix the width of this content.

    if you wont, his width will stretch just as it needs to.

    this will scroll

    CSS:

    *
    {
        margin: 0;
        padding: 0;
    }
    
    html, body, .Container
    {
        height: 100%;
    }
    
        .Container:before
        {
            content: '';
            height: 100%;
            float: left;
        }
    
    .Header
    {
        margin-bottom: 10px;
        background-color: #6ea364;
    }
    .Content
    {
        position: relative;
        z-index: 1;
    }
        .Content:after
        {
            content: '';
            clear: both;
            display: block;
        }
    
    .Wrapper
    {
        position: absolute;
        width: 100%;
        height: 100%;
    }
        .Wrapper > div
        {
            height: 100%;
        }
    
    .LeftContent
    {
        background-color: purple;
        overflow: auto;
    }
    
    .RightContent
    {
        background-color: orange;
        float: right;
        margin-left: 10px;
    }
    

    Bonus: with a little change in the CSS, you can create a beautiful scrolling. See that Fiddle

    Edit: If you want to set a width value to the left side, that is actually bigger then the body size (and to have an horizontal scroll), do it that way.

    <-- better to aplly the width from the CSS ....

提交回复
热议问题