在移動端,可以使用flex布局
給你個例子:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <style> * { padding: 0; margin: 0; } html, body { height: 100%; } .container { height: 100%; display: flex; flex-direction: column; } .body { flex: 1; background: red; } .footer { height: 100px; width: 100%; } </style> </head> <body> <div class="container"> <div class="body"></div> <div class="footer"></div> </div> </body> </html>