```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Switch ON</title> <style> .container { width: 100vw; height: 100vh; position: relative; } .circle { width: 50px; height: 50px; border-radius: 50%; background: yellow; position: absolute; top: 0; left: 50%; transform: translateX(-50%); } .rectangle { width: 100px; height: 100px; background: aqua; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); } </style> </head> <body> <div class="container"> <div class="circle"></div> <div class="rectangle"></div> </div> <script> let switchStatus = true; // スイッチがONかどうかの状態 function generateCircle() { let circle = document.querySelector('.circle'); circle.style.top = '0'; // 初期位置に配置 let interval = setInterval(function() { let topPos = parseInt(circle.style.top, 10); if(topPos >= window.innerHeight - 50) { // 画面下端に到達 clearInterval(interval); circle.style.display = 'none'; } else { circle.style.top = topPos + 1 + 'px'; // 下に移動 if(topPos >= window.innerHeight/2 && topPos <= window.innerHeight/2 + 100) { // 四角形の範囲に入ったら消える clearInterval(interval); circle.style.display = 'none'; } } }, 10); } setInterval(function() { if(switchStatus) { let circle = document.querySelector('.circle'); circle.style.display = 'block'; generateCircle(); } }, 2000); </script> </body> </html> ```