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. 引入traits后,為什么index得是空的呢?2. java - 如何理解“不要通過共享內存來通信,而應該通過通信來共享內存”?3. javascript - 如何在NW.JS中使用Node自動重啟進程?4. javascript - table固定尾行,有人寫過嗎?5. gulp-ruby-sass編譯出來的文件有錯6. dockerfile - docker-compose啟動lnmp失敗?7. 為什么學習PHP8. javascript - 使用node.js的ws模塊不斷地向客戶端發送消息,應該如何不斷地去觸發“發送”這個動作9. javascript - 為什么會打印兩次啊?10. angular.js使用$resource服務把數據存入mongodb的問題。
