css3移动端布局
问题描述
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>
问题解答
回答1:这种布局使用 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;}
前缀使用 autoprefixer 自动生成,浏览器的兼容性很理想。下面是 codepen 中的效果:
http://codepen.io/yuezk/pen/NqEqVv
相关文章:
1. angular.js - ng-grid 和tabset一起用时,grid width默认特别小2. vim - docker中新的ubuntu12.04镜像,运行vi提示,找不到命名.3. python for循环中的函数只能运行一次?4. css - transform-origin 旋转参考点5. java - socket类服务端如何防止被ddos攻击?6. javascript - Vue.js2.0不能使用debounce后大伙一般是如何解决延迟请求的问题的呢。7. python的文件读写问题?8. 请问是对象还是数组9. python - 有什么好的可以收集货币基金的资源?10. Python 匹配并删除redis的key
