In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use jquery to achieve page pinball effect", the content is easy to understand, clear, hope to help you solve your doubts, the following let Xiaobian lead you to study and learn "how to use jquery to achieve page pinball effect" this article.
The details are as follows
Like the windows screensaver, the ball bounces in the page and changes as the page changes.
As shown below:
Source code
Untitled document * {margin:0px; padding:0px;} # container {width:800px; height:500px; background:#FFF; margin:0px auto; margin-top:100px;} # b1 {width:50px; height:50px; background-color:#FFCCCC; border-radius:100%; position:fixed } # b2 {width:80px; height:80px; background-color:#9EC0C9; border-radius:100%; position:fixed;} # b3 {width:60px; height:60px; background-color:#336633; border-radius:100%; position:fixed } / / call the mobile floating window method and pass in the correct parameters in order ["obj", x _ journal _ lpl _ r _ m] Obj required / * move_w: width that can be moved move_h: height that can be moved x: speed of movement left and right y: speed up and down l: value of initial left t value of initial top m: time * / function move_obj (obj, x, y, l, t M) {if (obj = = undefined) {alert ("method call error, please pass the correct parameter!") Return;} / / current browser window size move_w = $(window). Width (); move_h = $(window). Height (); / / if the browser window size changes $(window) .resize (function () {move_w = $(window). Width (); move_h = $(window). Height ();}) / / moving speed and initial position x = (x = = undefined | | x = =')? 3: X; y = (y = = undefined | | y = ='')? 3: y; l = (l = = undefined | | l = ='')? 0: 1; t = (t = = undefined | | t ='')? 0: t; m = (m = = undefined | | m = ='')? 80: M / / Mobile function moving () {if (l > = move_w-$(obj) .width () | l
< 0 ){ //如果碰到浏览器左右壁 x = -x; } if(t >= move_h-$(obj) .height () | t < 0) {/ / if you encounter the upper and lower walls of the browser y =-y;} l + = x; t + = y; $(obj) .css ({/ / change the location of div left: l, top: t}) } var timer_move = setInterval (function () {moving ();}, m); $(obj) .mouseover (function () {clearInterval (timer_move);}); $(obj) .mouseout (function () {timer_move = setInterval (function () {moving ();}, m);}) } move_obj ("# b1", 30Magne10300300100); move_obj ("# b2"); move_obj ("# b3",-20Jing 30pr 600pm 500pc50); above is all the content of this article "how to use jquery to achieve page pinball effect". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.