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. 请教各位大佬,浏览器点 提交实例为什么没有反应2. PHP类中的$this3. javascript - 百度坐标,返回目标附近有哪些坐标4. javascript - 关于jsp中嵌入js代码的问题5. boot2docker无法启动6. Java Runtime.getRuntime()。exec()调用数百次后失败7. javascript - 初学angularJS+express,路由路径中/转换成%2F,导致路径失效,求原因?8. html5 - 只用CSS如何实现input框的宽度随框里输入的内容长短自动适应?9. html - 急求,能否用flex或者高端点的CSS来布局这个图呢?不想用浮动或定位了10. php可以定位客户端嘛

网公网安备