css3移动端布局
天蓬老师
天蓬老师 2017-04-17 11:17:40
0
1
472
css3有什么技巧能让section的高度加上header和footer的高度正好是屏幕的高度
不能用定位的,这关系到安卓的软键盘会把页面向上顶
---css---
.indexPage{
    width:100%;
    height:100%;  
    overflow:hidden; 
}
.indexPage header{
    height:100px;
    overflow:hidden;
}
.indexPage section{
     width:100%;
     overflow:hidden;
}
.indexPage footer{
     height:100px;
     overflow:hidden;
}

---html---
        <article class="indexPage">
            <header></header>
            <section></section>
            <footer></footer>
        </article>
天蓬老师
天蓬老师

欢迎选择我的课程,让我们一起见证您的进步~~

reply all(1)
PHPzhong

This layout is perfect to use flex.

csshtml,
body {
  height: 100%;
}

body {
  margin: 0;
}

article {
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
}

header {
  height: 50px;
  background: #ccc;
}

footer {
  height: 50px;
  background: #ccc;
}

section {
  flex: 1;
  background: #eee;
}
The

prefix is ​​automatically generated using autoprefixer, and the browser compatibility is ideal. The following is the effect in codepen:

http://codepen.io/yuezk/pen/NqEqVv

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template