CSS flex显示Chrome / IE和Edge之间的差异?

时间:2017-04-23 07:10:47

标签: html css flexbox

我有一个像下面这样的html片段。在Chrome和IE浏览器上,垂直滚动条显示在divSub2内,但在Edge中,divSub2上的垂直滚动条不显示,而是显示在正文上。如何在Edge上运行它,比如Chrome或IE?

<html>
<head>
    <style type="text/css">
        body,html{
            height:100%;
            width:100%;
            padding:0;
            margin:0;
        }
        body{
            display:flex;
            flex-flow:column;
        }
        .divTop{
            height:100px;
            width:100%;
        }
        .divBottom {
            height: 100px;
            width: 100%;
        }
        .divMain{
            width:100%;
            flex:1;
            background-color:lightblue;

            display:flex;
            flex-flow:column;
        }
        .divSub1{
            height:40px;
            width:100%;
        }
        .divSub2{
            flex:1;
            overflow-y:auto;
            height:100%;
            background-color:aqua;
        }
    </style>
</head>
<body>
    <div class="divTop">
    </div>
    <div class="divMain">
        <div class="divSub1">
        </div>
        <div class="divSub2">
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
            <p>Text</p>
        </div>
    </div>
    <div class="divBottom">
    </div>
</body>
</html>

截图: The vertical scrollbar displayed on body, in Edge

1 个答案:

答案 0 :(得分:1)

在divSub2上添加属性height:0;