css - div 自適應高度 自動填滿剩餘高度
过去多啦不再A梦
过去多啦不再A梦 2017-05-31 10:40:40
0
3
1039

固定的盒子需要絕對定位才能達到以下效果,希望有不需要絕對定位實現以下方法的大神!求指點

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
    html,
    body {
        height: 100%;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
    
    .outer {
        height: 100%;
        padding: 100px 0 0;
        box-sizing: border-box;
    }
    
    .A {
        height: 100px;
        background: #BBE8F2;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
    }
    
    .B {
        height: 100%;
        background: #D9C666;
        overflow: scroll;
    }
    </style>
</head>

<body>
    <p class="outer">
        <p class="A"> 头部p </p>
        <p class="B">
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdfD</p> <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>abcabsdf</p>
            <p>sssssssssssssssssssssss</p>

         </p>
    </p>
</body>

</html>
过去多啦不再A梦
过去多啦不再A梦

全部回覆(3)
巴扎黑

問題有點模糊,如果是要求A+B等於outer的高度,可以用calc(100% - 100px);

PHPzhong

浮動 固定定位

迷茫

你的問的不太明白啊,能說的具體點嗎?

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板