代码学习:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Nearth</title> <style type="text/css"> .{ margin: 0; padding: 0; } body{ background-image: url(0.jpg); background-repeat: no-repeat; background-attachment: fixed; background-size: 100% 100%; } div{ width:50px; height: 50px; background-color:orange; position:relative; left:100px; top:50px; } </style> <script src="jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(function(){ $("#btn").click(function(){ $("#dv").offset({"left":200,"top":200}); }); }); </script> </head> <body> <h1>关于left和top的问题</h1> <hr > <input type="button" name="" id="btn" value="显示效果" /> <div id="dv"></div> </body> </html>