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. IOS app應用軟件的id號怎么查詢?比如百度貼吧的app-id=4779278132. css - 一條線兩邊有短線的樣式表怎么寫?3. angular.js - ASP.NET Webform 中能使用 AngularJS 嗎?4. python 中如何自動安裝第三方庫?5. css - 為什么我沒見到一個瀏覽器支持多重偽元素和嵌套偽元素?6. java - 同步/異步與阻塞/非阻塞之間的差異具體是什么?7. javascript - node.js中stat() access() open() readFile()都能判斷文件是否存在?8. node.js - nodejs中把熱request保存下來,使用JSON.stringify(req)報錯,請問怎么解決?9. .gitignore 如何僅忽略根目錄下的index.html10. css - 移動端 盒子內加overflow-y:scroll后 字體會變大
