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. docker-machine添加一個已有的docker主機問題2. java-ee - JAVA的注解@Api和@ApiOperation的作用是什么,怎么跳轉頁面的3. java - mybatis會自己緩存自己生成過的prestatement嗎4. java - 原生CGLib內部方法互相調用時可以代理,但基于CGLib的Spring AOP卻代理失效,為什么?5. java - tomcat服務經常晚上會掛,求解?6. node.js - node express 中ajax post請求參數接收不到?7. apache - nginx 日志刪除后 重新建一個文件 就打不了日志了8. 怎么能做出標簽切換頁的效果,(文字內容隨動)9. mysql - mongo如何對一個collection進行順序上的調整呢?10. chrome瀏覽器怎么使用
