【发布时间】:2018-03-23 13:59:29
【问题描述】:
困难的问题是我需要这条 CSS 规则:html {height: 100%} 才能使我的第一页正常工作。见prototype。
这允许登录 div 基于窗口的高度居中。
但是,第二页现在停留在这个高度,并且在我使用 ajax 填充内容时不会扩展。点击星号in this link 或见下文。
您可以看到虚线停止的位置是窗口在 100% 时的原始渲染。
如果我删除 100% 的高度,它会扩展,但登录页面会因为没有高度而损坏。
注意:React 是根据应用程序状态在 JSX 中使用一个简单的条件来控制从页面到另一个页面的变化。
我应该根据应用程序状态更改 HTML 的 CSS 高度还是有更好的方法来做到这一点?
一个更好的问题可能是,在 div 中的内容更改后,div 是否应该扩展以反映这一点?
相关 CSS
html{
width: 100%;
height: 100%;
}
body{
background-image: url('_images/bg_paper.jpg');
height: 100%;
width: 100%;
}
#app{
width: 100%;
height: 100%;
}
#contents{
width: 100%;
height: 100%;
}
#top-1{
position: fixed;
width: 100%;
height: 40px;
background: rgba(255, 255, 255, 0.8);
border-top: 3px solid #000000;
border-bottom: 1px solid #bbbbbb;
z-index: 1000;
}
#top-2{
position: relative;
width: 90%;
height: 100%;
margin: 0 auto;
border-left: 1px dotted #888888;
border-right: 1px dotted #888888;
}
#container-1{
position: relative;
display: inline-block;
width: 100%;
height: 100%;
top: 44px;
}
#container-2{
position: relative;
width: 90%;
height: 100%;
margin: 0 auto;
border-left: 1px dotted #888888;
border-right: 1px dotted #888888;
}
.body{
display: none;
position: relative;
width: 100%;
height: 100%;
}
【问题讨论】:
-
使用
min-height: 100%而不是height: 100%。另外,从html中删除这些标签,并仅在body中使用它们。 -
从
html中删除width和height?并将min-height添加到body设置为 100%。原因是什么? -
我试过了,还是不行。
-
为登录创建一个特殊类,使其相应定位并移除高度。
标签: javascript css reactjs jsx