|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>放大框</title>
- <style>
- .one{
- width:500px;
- height:500px;
- margin:0 auto;
- background-color:gold;
- }
- .twoo{
- width:200px;
- height:200px;
- background-color:rgba(100,100,100,.4);//字不会有透明效果。
- /* opacity:0.8; *///字有透明效果。
- }
-
-
- </style>
- </head>
- <body>
- <div class='one'>
- <div class='twoo'>222</div>
- </div>
- <script>
- const one=document.querySelector('.one');
- const twoo=document.querySelector('.twoo');
-
- twoo.addEventListener('mousedown',function(e){
-
- document.addEventListener('mousemove',move);
- function move(e){
- twoo.style.top=y+'px';
- twoo.style.left=x+'px';
- var x=e.pageX-one.offsetLeft;
- var y=e.pageY-one.offsetTop;
- console.log( twoo.style.top);//////////////////////问题
- };
- document.addEventListener('mouseup',function(){
- document.removeEventListener('mousemove',move);
- });
- });
-
- </script>
- </body>
- </html>
复制代码
同样也是用 console.log( twoo.offsetTop);
麻烦把前面的贴子都结贴。
|
|