【发布时间】:2019-08-19 08:29:07
【问题描述】:
我正在开发一个 SPA 应用程序,该应用程序也将具有响应式设计。
计划是有一个固定高度的标题(30 像素),然后是填充的内容,和一个固定高度的页脚(20 像素)。就像 winforms 中的 TableLayoutPanel (Absolute:30,Percent:100%,Absoulte:20)。
由于视口的大小,内容区域填满了整个可用空间,并且不会导致溢出以显示浏览器的滚动条。相反,内容区域有一个内部滚动条。所有的内容都会在这个区域加载,所以如果需要它会显示滚动条。
当我搜索并与 SO 朋友交流时,我找到了这个解决方案:
<div class="shell">
<header class="shell-header">Header Info</header>
<div class="main-row">
<div class="main-scroll">
<section class="main"
data-bind="router: { transition: 'entrance', cacheViews: true }">
</section>
</div>
</div>
<footer class="shell-footer">Footer Info</footer>
这是样式:
.shell {
height: 100%;
display: table;
width: 100%;
}
.shell-header {
width: 100%;
display: table-row;
height: 30px;
}
.shell-footer {
width: 100%;
display: table-row;
height: 20px;
}
.main-row {
display: table-row;
height: 100%;
width: 100%;
}
.main-scroll {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: #F5F5F5;
display: block;
height: 100%;
margin: auto;
max-width: 1100px;
position: relative;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
}
.main {
height: 100%;
background-color: whitesmoke;
max-width: 1100px;
width: 100%;
position: absolute;
display: block;
}
此解决方案在 Firefox 和 Chrome 上运行良好,调整大小后一切正常。
但在 IE 10 中,div class="main-scroll" 没有填充它的父级,它的高度在布局中是 0px。
问题 1: 为什么会这样?
问题 2: IE10 的解决方法是什么?
【问题讨论】:
-
尝试将
-ms-box-sizing: border-box;添加到您的.main-scroll -
@AdrianEnriquez 不,它没有任何效果。 thie
box-sizing似乎从 IE 8 开始就受到支持,它的-ms版本似乎适用于旧版本。 -
赞成你的问题。
标签: css html internet-explorer single-page-application