我们可以用代码来验证代码如下:
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title> 无标题文档 </title>
- <style>
- #gd{
- width:500px;
- height:500px;
- background:red;
- position:fixed;
- }
- #jd{
- width:300px;
- height:300px;
- background:blue;
- position:absolute;
- left:400px;
- top:1000px;
- }
- </style>
- </head>
- <body>
- <div id="jd">
- 我是绝对定位
- </div>
- <div id="gd">
- 我是固定定位
- </div>
- </body>
- </html>
来源: http://www.bubuko.com/infodetail-2685903.html