我正在开发一个带有html5 / JS的Windows 8商店应用程序,一个阅读应用程序。内容页面如下所示:
我正在使用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内容,即使conent的高度大于容器,也没有滚动条。
那么,我该如何解决这个问题?
答案 0 :(得分:1)
首先从CSS中删除“.contentPagepage
.content
#contentContainer
”块。
然后将#rightContainer
和#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%;
}