第一篇博客,哇哈哈哈哈哈!
作为一个前端新人,整理了一些关于html高度和页面布局的问题。
在涉及高度的时候,我目前使用的属性有:height,min-height,以下是整理的几种使用情况:
1、height
html{
height:100%;
width: 100%;
}
body{
height:100%;
width: 100%;
margin: 0;
}
.content{
#这是body中子元素的类
height: 1000px;
background-color: aqua;
}
此时,子元素的高度大于html的高度(不适合应用于有左侧导航栏且导航栏有背景色的情况)
2、min-height
html{
min-height: 100%;
}
body{
min-height: 100%;
margin: 0;
}
.content{
height: 1000px;
background-color: aqua;
}
此时content中如果设置height:100%是无效的。
3、让content的高度可以完美适应html高度(当content较小时还可以给body设置背景沾满屏幕,content较大时html和body也能随着变大)
html{
height: 100%;
width: 100%;
display: table;
background-color: burlywood;
}
body{
height: 100%;
width: 100%;
display: table-cell;
}
.content{
#height: 1000px;
height: 100%;
background-color: aqua;
}
先写这么多,比较乱,慢慢改进!!!