###前提・実現したいこと
どーもこーも動いてくれません。。
要はbox2を任意の場所(page2)に移動させたいのですが、animateがうまく機能しません。
例えばanimate({top:"400px"})とかでは動くのですが、animate({scrollTop:GoTop})は動きません。
これは、どういうことなのでしょうか??
教えてください。。
よろしくお願いいたします!!!!!!!!
<head> <style> #page1{ position:relative; width:100%; height:800px; background-color:#39C; } #page2{ position:relative; width:100%; height:1000px; background-color:#6C9; } #box1{ position:relative; width:100px; height:100px; top:-100px; background-color:#999; display:none; } #box2{ position:relative; left:200px; top:100px; width:300px; height:400px; background-color:#C33; } #box3{ position:relative; left:400px; top:100px; width:200px; height:400px; background-color:#C3C; transition:all 3s ease 0; } </style> </head> <body> <section id="page1"> </section> <section id="page2"> <div id="box1">hello</div> <div id="box2">world</div> <div id="box3">go</div> </section> <script> $(function(){ var Flag = false $(window).scroll(function(){ var scr_counting = $(document).scrollTop() if(scr_counting >= 700 && Flag === false ){ $("#box1").show().animate({ top:"0px", opacity:"0.7" }) Flag = true return }else if( scr_counting < 699 && Flag === true){ $("#box1").animate({ top:"-100px", opacity:"0" }) Flag = false return } }) $('#box2').click(function(){ var GoTop = $("#page2").offset().top; var GoLeft = $("#page2").offset().left; $('#box3').animate({ scrollTop: GoTop, scrollLeft: GoLeft }); return false; }); }) </script> </body>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。