创建固定 html 布局
Creating a fixed html layout
我将如何创建一个 HTML 布局,它在顶部有一个固定的工具栏,在底部有一个固定的工具栏 - 以及一个居中的 DIV(居中,垂直和水平)。另外,当用户调整 window.
大小时,我试图让居中 DIV 响应
我添加了一个 mockup/screenshot:
这有帮助吗?
html, body{
margin: 0;
height: 100%;
background-color: #555;
}
#topToolBar{
position: absolute;
top: 0;
height: 50px;
width: 100%;
background-color: #ccc;
}
#bottomToolBar{
position: absolute;
bottom: 0;
height: 50px;
width: 100%;
background-color: #ccc;
}
#centerDivWrapper{
width: 80%;
height: 100%;
margin: 0 auto;
}
#centerDiv{
padding: 55px 0;
height: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#centerDivContent{
width: 100%;
height: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
border: solid 3px #000;
overflow-y: auto;
}
<div id="topToolBar"></div>
<div id="centerDivWrapper">
<div id="centerDiv">
<div id="centerDivContent">
Lorem ipsum dolor sit amet
</div>
</div>
</div>
<div id="bottomToolBar"></div>
我将如何创建一个 HTML 布局,它在顶部有一个固定的工具栏,在底部有一个固定的工具栏 - 以及一个居中的 DIV(居中,垂直和水平)。另外,当用户调整 window.
大小时,我试图让居中 DIV 响应我添加了一个 mockup/screenshot:
这有帮助吗?
html, body{
margin: 0;
height: 100%;
background-color: #555;
}
#topToolBar{
position: absolute;
top: 0;
height: 50px;
width: 100%;
background-color: #ccc;
}
#bottomToolBar{
position: absolute;
bottom: 0;
height: 50px;
width: 100%;
background-color: #ccc;
}
#centerDivWrapper{
width: 80%;
height: 100%;
margin: 0 auto;
}
#centerDiv{
padding: 55px 0;
height: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
#centerDivContent{
width: 100%;
height: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: #fff;
border: solid 3px #000;
overflow-y: auto;
}
<div id="topToolBar"></div>
<div id="centerDivWrapper">
<div id="centerDiv">
<div id="centerDivContent">
Lorem ipsum dolor sit amet
</div>
</div>
</div>
<div id="bottomToolBar"></div>