码迷,mamicode.com
首页 > Web开发 > 详细

关于 web 页面 占满全屏

时间:2018-12-24 13:26:24      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:body   cal   ack   style   关于   flex   bsp   div   display   

 页面一般可以分成三部分,头部,底部,中间内容部分。

一般不用考虑中间高度部分,因为可以靠内容撑开,然后让底部到达底部。但是当中间内容太少时,底部就会顶不到底部。

方法1、中间部分给一个最小高度(min-height = 100vh - 头部高度 - 底部高度).

 1     header,
 2     footer {
 3       height: 100px;
 4       background-color: #234abc;
 5       color: #ffffff;
 6     }
 7 
 8     .content {
 9       min-height: calc(100vh - 200px);
10       /* flex: 1; */
11       background-color: green;
12     }

 

方法2、flex 布局

 1     html,body {
 2       min-height: 100%;
 3       display: flex;
 4       flex: 1;
 5       flex-direction: column;
 6     }
 7 
 8     header,
 9     footer {
10       height: 100px;
11       background-color: #234abc;
12       color: #ffffff;
13     }
14 
15     .content {
16       flex: 1;
17       background-color: green;
18     }

关于 web 页面 占满全屏

标签:body   cal   ack   style   关于   flex   bsp   div   display   

原文地址:https://www.cnblogs.com/xguoz/p/10168010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!