Div height percentage based but still scrolling

后端 未结 2 1632
小蘑菇
小蘑菇 2021-02-09 15:33

First off, similar but never answered questions:

vertically-scrolling-percentage-based-heights-vertical-margins-codepen-exampl

scroll-bar-on-div-with-overflowau

2条回答
  •  执笔经年
    2021-02-09 15:56

    You want something like This

    Or maybe - his big brother..

    Pure CSS solution, without fixing any height.

    HTML:

    CSS:

    *
    {
        margin: 0;
        padding: 0;
    }
    
    html, body, .Container
    {
        height: 100%;
    }
    
        .Container:before
        {
            content: '';
            height: 100%;
            float: left;
        }
    
    .First
    {
        /*for demonstration only*/
        background-color: #bf5b5b;
    }
    
    .Second
    {
        position: relative;
        z-index: 1;
        /*for demonstration only*/
        background-color: #6ea364;
    }
    
        .Second:after
        {
            content: '';
            clear: both;
            display: block;
        }
    
    .Content
    {
        position: absolute;
        width: 100%;
        height: 100%;
        overflow: auto;
    }
    

提交回复
热议问题