成人精品一区二区三区中文字幕-成人精品一区二区三区-成人精品一级毛片-成人精品亚洲-日本在线视频一区二区-日本在线视频免费

導航首頁 ? 技術教程 ? jQuery+css實現炫目的動態塊漂移效果
全站頭部文字 我要出現在這里
jQuery+css實現炫目的動態塊漂移效果 687 2024-03-12   

本文實例講述了jQuery+css實現的動態塊漂移效果.分享給大家供大家參考,具體如下:

運行效果截圖如下:

查看圖片

具體代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title></title>
  <script src="http://www.gimoo.net/t/1903/jquery-1.7.1.min.js" type="text/javascript"></script>
  <script type="text/javascript" >
    function createColor() {
      var color = [];
      for (var i = 0; i < 3; i++) {
        color.push(Math.round(Math.random() * 256));
      }
      return "rgb(" + color.join(",") + ")"
    }
    function createRect(left, top, index) {
      var width = Math.round(Math.random() * 150) + 10;
      var height = Math.round(Math.random() * 150) + 10;
      left = left > width ? left - width : left;
      top = top > height ? top - height : top;
      var html = [];
      html.push('<div id="rect_'+index+'" class="rect shadow radius" style="background:');
      html.push(createColor());
      html.push(';left:');
      html.push(left);
      html.push('px;top:');
      html.push(top);
      html.push('px;width:');
      html.push(width);
      html.push('px; height:');
      html.push(height);
      html.push('px;"></div>');
      return html.join("");
    }
    function initRect() {
      var body = $("#body");
      var width = body.width();
      var height = body.height();
      var index = new Date().getTime();
      body.append(createRect(Math.round(Math.random() * width), Math.round(Math.random() * height), index));
      setAnimate(index, height);
    }
    function setAnimate(index, height) {
      var rect = $("#rect_" + index);
      var top = parseInt(rect.position().top);
      var selfHeight = rect.height();
      if (top > height - selfHeight) {
        rect.remove();
        initRect();
      } else {
        var filter = top / height;
        rect.css({ "top": (top + 5) + "px", "opacity": filter });
        setTimeout(function () {
          setAnimate(index, height);
        }, 33);
      }
    }
    function initAllRect() {
      for (var i = 0; i < 20; i++) {
        initRect();
      }
    }
    $(document).ready(function () {
      initAllRect();
    });
  </script>
  <style type="text/css" >
  .rect {
        background:#DDDDDD;
        width:100px;
        height:100px;
        position:absolute;
  }
  .radius 
  {
    border-radius:8px;
      -moz-border-radius:8px;
      -webkit-border-radius:8px;
  }
  .shadow 
  {
    -moz-box-shadow:-5px -5px 5px #999 inset;
      -webkit-box-shadow:-5px -5px 5px #999 inset;
      box-shadow:-5px -5px 5px #999 inset; 
  }
  #body { height:700px; width:100%; background:black; margin:0; }
  </style>
</head>
<body>
<div id="body" class="shadow radius">
</div>
</body>
</html>

更多關于jQuery相關內容感興趣的讀者可查看本站專題:《jQuery動畫與特效用法總結》及《jQuery常見經典特效匯總》

希望本文所述對大家jQuery程序設計有所幫助。


css

主站蜘蛛池模板: 叶子楣图片| 13位的电话号码是什么电话| 二阶堂富美| 乡村女老师| 齐士龙| cctv16节目单| 我不知道明天的道路歌词歌谱| 孙嘉欣| 儿童眼轴长度正常范围| 墨雨云间电视剧免费播放| 扫毒风暴| 高一英语必修一| 欧美日韩欧美日韩在线观看视频| 端午节手抄报一年级| 果晓丹| 电影《大突围》免费观看国语| 郑荣植个人资料| 邯郸学步成语故事完整版| 风云太白山电影| 焕羽电视剧免费播放在线观看| 老炮儿演员表| 抖音网页版登录入口| 死亡繁殖| stylistic device| 希比·布拉奇克| 赫伯曼电影免费观看| 红色电视剧| xxxxxxcom| 色戒在线观看完整版免费| 我在等你回家剧情介绍| 光荣之路| 红楼影视| cgtn news在线直播| 天上人间电影| 黑色的太阳| 内蒙古电视台雷蒙| 87版七仙女台湾| 漂亮主妇 电视剧| 小酒窝| 大尾鲈鳗| 跟班服务|

!!!站長長期在線接!!!

網站、小程序:定制開發/二次開發/仿制開發等

各種疑難雜癥解決/定制接口/定制采集等

站長微信:lxwl520520

站長QQ:1737366103