适应手机浏览器,元素固定在页面底部
html和css代码如下:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" /> <title>底部固定</title> <style type="text/css"> * { padding: 0; margin: 0; } html, body { height: 100%; position: relative; } #wrap { height: 100%; overflow: auto; } #main { padding-bottom: 60px; } #footer { background-color: #e6d9d9; position: absolute; height: 60px; left: 0; right: 0; bottom: 0; } </style> </head> <body> <div id="wrap"> <div id="main"> 主体 <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>1</div> <div>最后一个元素</div> </div> </div> <div id="footer"> 这里是页底footer内容 </div> </body> </html>

浙公网安备 33010602011771号