1

我正在开发一个带有 html5/JS 的 Windows 8 Store 应用程序,一个阅读应用程序。内容页面如下所示: 在此处输入图像描述

我正在使用 CSS-Grid-Layout 来管理页面布局,如下所示:

<body>
    <div class="contentPagepage fragment">
        <header aria-label="Header content" role="banner">
            <button class="win-backbutton black-button" aria-label="Back" disabled type="button"></button>
            <h1 class="titlearea win-type-ellipsis">
                <span class="pagetitle"></span>
            </h1>
            <h2>
                <span class=""></span>
            </h2>
        </header>
        <div class="content clearfix" aria-label="Main content">
            <div id="leftContainer">
                <p>Left container</p>
            </div>

            <section id="rightContainer">
                <div id="navContainer">
                    <button type="button">button 1</button>
                    <button type="button">button 2</button>
                    <button type="button">button 3</button>
                </div>
                <!--<article>-->
                    <div id="contentContainer" class="item-content" aria-label="Main content">
                    html content 
                    </div>
            </section>

        </div>

    </div>
</body>

而css文件是:

.contentPagepage, .black-button {
    background-color: #EEEEEE;
    color: black;
}

.clear{ clear: both; }
.clearfix:after{ 
content:"."; display:block; height:0; clear:both; 
visibility:hidden; 
font-size: 0;
}

*html .clearfix{ 
 height:1%; 
}

*+html .clearfix{ 
 height:1%; 
}

.contentPagepage .content {
    -ms-grid-row-span: 2;
    display: -ms-grid;
    -ms-grid-columns: 40% 60%;
    height: calc(100% - 183px);
    margin: 133px 120px 0 120px;
    border: 1px solid #000;
}

#leftContainer {
    height: calc(100% - 183px);
    -ms-grid-column: 1;
    background-color: greenyellow;
    margin: 0 10px 10px 0;
}

#rightContainer{
    -ms-grid-column: 2;
    display: -ms-grid;
    -ms-grid-rows: 30px auto;
}

#navContainer {
    -ms-grid-row: 1;
}

#contentContainer {
    -ms-grid-row: 2;
    overflow-y: auto;
    height: calc(100% - 0px);
}

.contentPagepage .content #contentContainer {
    -ms-grid-row: 2;
    height: auto;
    background-color: red;
    display: block;
    overflow-y: auto;
}

现在布局系统工作正常,但内容区域也得到了修复,这意味着如果我使用 "lement.querySelector(".content .item-content").innerHTML = item.content;" 要加载一些 html 内容,即使内容的高度大于容器,也没有滚动条。

那么,我该如何解决这个问题呢?

4

1 回答 1

1

首先.contentPagepage .content #contentContainer从 CSS 中删除 " " 块。然后将#rightContainerand替换为#contentContainer

#rightContainer{
    -ms-grid-column: 2;
    -ms-grid-rows: 30px 1fr;
    display: -ms-grid;
    height: calc(100% - 183px);
}

#contentContainer {
    -ms-grid-row: 2;
    overflow-y: scroll;
    background-color: red;
    height: 100%;
}
于 2013-01-04T11:59:25.163 回答