代码描述:css元素 网页底部。css将元素固定于网页底部
本章节介绍一下如何让一个div元素固定于网页的底部。 这种效果具有两种情况,一种是随着滚动条滚动,另一种情况是不随着滚动条滚动。 下面分别通过代码实例介绍一下: 实例代码:
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.51qianduan.com/" /> <title>51前端</title> <style type="text/css"> html,body{ margin:0px; padding:0px; height:1000px; width:100%; } #footer{ height:30px; background:#CCC; position:fixed; bottom:0px; width:100%; text-align:center; font-size:12px; line-height:30px; } </style> </head> <body> <div id="footer">51前端欢迎您,只有努力才会有美好的明天。</div> </body> </html>
上面的代码可以将div元素固定于网页的底部,不会随着滚动条的滚动而变化。
<!DOCTYPE html> <html> <head> <meta charset=" utf-8"> <meta name="author" content="http://www.51qianduan.com/" /> <title>51前端</title> <style type="text/css"> html,body{ margin:0px; padding:0px; height:1000px; width:100%; } #footer{ height:30px; background:#CCC; position:absolute; bottom:0px; width:100%; text-align:center; font-size:12px; line-height:30px; } </style> </head> <body> <div id="footer">51前端欢迎您,只有努力才会有美好的明天。</div> </body> </html>
请绑定手机号,在继续操作
注意:只有绑定手机以后,才可使用网站全部功能