评论

收藏

[JSP] jsp图片效果大全(图像震动效果、闪烁效果、自动切换图像

开发技术 开发技术 发布于:2021-10-20 20:55 | 阅读数:549 | 评论:0

本文主要介绍jsp实现图像震动效果、闪烁效果、自动切换图像的资料,废话不多说了,具体代码如下:

1.当鼠标指针经过图像时图像震动效果
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="https://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>当鼠标指针经过图像时图像震动效果</title>
  6. <style type="text/css">
  7. .zhendimage{ position:relative; }
  8. </style>
  9. <script type="application/javascript" >
  10. var rector =3;
  11. var stopit = 0;
  12. var a=1;
  13. var zhend;
  14. function init(which)
  15. {
  16.   stopit =0;
  17.   zhend = which;
  18.   zhend.style.left =0;
  19.   zhend.style.top =0;
  20. }
  21. function rattleimage()
  22. {
  23.   if(stopit==1)
  24.   {
  25.     return;
  26.   }  
  27.   if(a==1)
  28.   {
  29.     zhend.style.top = parseInt(zhend.style.top)+rector+"px";
  30.   }
  31.   else if(a==2)
  32.   {
  33.     zhend.style.left = parseInt(zhend.style.left)+rector+"px";
  34.   }
  35.   else if(a==3)
  36.   {
  37.     zhend.style.top = parseInt(zhend.style.top)-rector+"px";
  38.   }
  39.   else
  40.   {
  41.     zhend.style.left = parseInt(zhend.style.left)-rector+"px";
  42.   }
  43.   if(a<4)a++;  else a =1;
  44.   setTimeout("rattleimage()",50);
  45. }
  46. function stoprattle(which)
  47. {
  48.   stopit = 1;
  49.   which.style.left =0;  
  50.   which.style.top =0;   
  51. }
  52. </script>
  53. </head>
  54. <body>
  55. <div>
  56. DSC0000.png </div>
  57. </body>
  58. </html>
2.图片闪烁效果
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="https://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>图片闪烁效果</title>
  6. <script type="application/javascript">
  7. function blink()
  8. {
  9. //定义图片的显示和隐藏属性
  10. tp.style.visibility = (tp.style.visibility=="hidden")?"visible":"hidden";  
  11. //每0.5秒刷新一次
  12. setTimeout("blink()",500);
  13. }
  14. </script>
  15. </head>
  16. <body >
  17. <div id="tp">
  18. DSC0001.jpg
  19. </div>
  20. </body>
  21. </html>
3.自动切换图像
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>自动切换图像</title>
<script type="application/javascript">
var imgs = new Array
(
"https://images.cnblogs.com/cnblogs_com/yc-755909659/559257/o_ycimg003.jpg",
"https://images.cnblogs.com/cnblogs_com/yc-755909659/559257/o_ycimg004.gif",
"https://images.cnblogs.com/cnblogs_com/yc-755909659/559257/o_%e6%9a%82%e6%97%a0%e5%9b%be%e7%89%87.gif"  
)
var nums =0;
setInterval("fort()",1000);
function fort()
{
  iimg.src = imgs[nums];  
  nums++;
  if(nums==3)nums=0;
}
</script>
</head>
<body>
<div></div>
</body>
</html>
希望本文所述对你有所帮助,jsp图片效果大全(图像震动效果、闪烁效果、自动切换图像)内容就给大家介绍到这里了。希望大家继续关注我们的网站!想要学习介绍jsp可以继续关注本站。

关注下面的标签,发现更多相似文章