用什麼代碼實現?不容許有白色底色產生,由於手機高度不同html
錯誤的寫法:加到div中結合圖片設置min-height,可是頁面不會回彈jquery
話很少說直接上代碼
html,body{ width:100%; height:100% }
再加一段緩存
body{ font-family: "華文細黑"; background:url("../img/Flyer-bg.png") no-repeat; background-size: 100%; }
就是這麼簡單,可是好多人想不到。ui
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,minimum-scale=1.0"> <title>緩存</title> <script src="js/jquery-1.8.2.min.js"></script> <script src="js/store.min.js"></script> <style> .parent{ width:200px; height: 200px; /* 如下屬性垂直居中 */ position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: auto; background-color: #aaa; } </style> </head> <body> <div class="parent">111</div> </body>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div id="Layer1" style="position:fixed; left:0px; top:0px; width:100%; height:100%"> <img src="https://www.qianbuxian.com/uploads/banners/20171214085954_shouye5.jpg" width="100%" height="100%"/> </body> </html>