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. node.js - mongodb查找子對象的名稱為某個值的對象的方法2. javascript - QQ第三方登錄的問題3. 測試自動化html元素選擇器元素ID或DataAttribute [關閉]4. 運行python程序時出現“應用程序發生異常”的內存錯誤?5. spring-mvc - spring-session-redis HttpSessionListener失效6. 在mac下出現了兩個docker環境7. 利用IPMI遠程安裝centos報錯!8. mysql - 查詢 修改數據庫優化問題吧9. 正在使用electron和node.js做桌面應用,需要實時監聽是否有網絡連接,node或者electron是否可以做到10. java - Spring boot 讀取 放在 jar 包外的,log4j 配置文件,系統有創建日志文件,不寫入日志信息。

網公網安備