本教程操作环境:windows7系统、css3版,DELL G3电脑。
css设置元素高度自适应的方法:
可以采用元素定位 + padding 的方式使特定元素高度自适应。
css 样式:
复制代码1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
html,body{
height:100%;
margin:0;
padding:0;
}
.wrap {
height:100%;
box-sizing: border-box ;
position: relative;
padding: 60px 0 0;
}
.header {
height: 60px;
position: absolute;
top: 0;
width: 100%;
}
.content {
height:100%;
}
登录后复制
html:
复制代码1
2
3
4
5
6
7
8
<div class="wrap">
<div class="header">
我是头部信息
</div>
<div class="content">
我要高度自适应
</div>
</div>
登录后复制
效果如下:
以上就是css如何设置元素高度自适应的详细内容,更多请关注靠谱客其它相关文章!
最后
以上就是单纯宝马最近收集整理的关于css如何设置元素高度自适应的全部内容,更多相关css如何设置元素高度自适应内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复