代码库
  • 首页
  • html模板
  • Jquery插件
  • 代码文章
  • 百宝箱
  • 网站导航
  • 编程代码
    • PHP
    • Jquery
    • DivCss
    • Mysql
    • linux
  • 程序代码
    • 织梦Cms
  • php
  • jquery
  • divcss
  • 网站建设500起 APP小程序独开
  • HTML模板全站下载388元
  • COMODO通配符SSL证书330元
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 广告位招租:515856299
  • 领取上云大礼包单笔最高立减1500元
  • 服务器0元试用,首购低至0.9元/月起

css3点击爆炸下落的特效代码

分类:DivCss人气:1929

一个代码简洁,效果明显的jquery+css3特效 点击p块状,会自动破碎并散落到网页底部

$(document).ready(function() {
    // Generate the clips. In this case I'm using 5 (or 25 pieces)
    (genClips = function() {
         
        // For easy use
        $t = $('.clipped-box');
         
        // Like I said, we're using 5!
        var amount = 5;
         
        // Get the width of each clipped rectangle.
        var width = $t.width() / amount;
        var height = $t.height() / amount;
         
        // The total is the square of the amount
        var totalSquares = Math.pow(amount, 2);
         
        // The HTML of the content
        var html = $t.find('.content').html();
         
        var y = 0;
         
        for(var z = 0; z <= (amount*width); z = z+width) {
         
            $('<p class="clipped" style="clip: rect('+y+'px, '+(z+width)+'px, '+(y+height)+'px, '+z+'px)">'+html+'</p>').appendTo($t);
             
            if(z === (amount*width)-width) {
             
                y = y + height;
                z = -width;
            }
             
            if(y === (amount*height)) {
                z = 9999999;
            }
        }
         
    })();
     
    // A quick random function for selecting random numbers
    function rand(min, max) {
         
        return Math.floor(Math.random() * (max - min + 1)) + min;
         
    }
     
    // A variable check for when the animation is mostly over
    var first = false,
        clicked = false;
     
    // On click
    $('.clipped-box p').on('click', function() {
         
        if(clicked === false) {
             
            clicked = true;
             
            $('.clipped-box .content').css({'display' : 'none'});  
     
            // Apply to each clipped-box p.
            $('.clipped-box p:not(.content)').each(function() {
                 
                // So the speed is a random speed between 90m/s and 120m/s. I know that seems like a lot
                // But otherwise it seems too slow. That's due to how I handled the timeout.
                var v = rand(120, 90),
                    angle = rand(80, 89), // The angle (the angle of projection) is a random number between 80 and 89 degrees.
                    theta = (angle * Math.PI) / 180, // Theta is the angle in radians
                    g = -9.8; // And gravity is -9.8. If you live on another planet feel free to change
                     
                // $(this) as self
                var self = $(this);
                 
                // time is initially zero, also set some random variables. It's higher than the total time for the projectile motion
                // because we want the squares to go off screen.
                var t = 0,
                    z, r, nx, ny,
                    totalt =  15;
                 
                // The direction can either be left (1), right (-1) or center (0). This is the horizontal direction.
                var negate = [1, -1, 0],
                    direction = negate[ Math.floor(Math.random() * negate.length) ];
                 
                // Some random numbers for altering the shapes position
                var randDeg = rand(-5, 10),
                    randScale = rand(0.9, 1.1),
                    randDeg2 = rand(30, 5);
                 
                // Because box shadows are a bit laggy (by a bit I mean 'box shadows will not work on inpidual clipped ps at all')
                // we're altering the background colour slightly manually, in order to give the ps differentiation when they are
                // hovering around in the air.
                var color = $(this).css('backgroundColor').split('rgb(')[1].split(')')[0].split(', '),
                    colorR = rand(-20, 20),  // You might want to alter these manually if you change the color
                    colorGB = rand(-20, 20),  // To get the right consistency.
                    newColor = 'rgb('+(parseFloat(color[0])+colorR)+', '+(parseFloat(color[1])+colorGB)+', '+(parseFloat(color[2])+colorGB)+')';
                 
                 
                // And apply those
                $(this).css({
                    'transform' : 'scale('+randScale+') skew('+randDeg+'deg) rotateZ('+randDeg2+'deg)',
                    'background' : newColor
                });
                  
                // Set an interval
                z = setInterval(function() {   
                     
                    // Horizontal speed is constant (no wind resistance on the internet)
                    var ux = ( Math.cos(theta) * v ) * direction;
                     
                    // Vertical speed decreases as time increases before reaching 0 at its peak
                    var uy = ( Math.sin(theta) * v ) - ( (-g) * t);
                     
                    // The horizontal position
                    nx = (ux * t);
                             
                    // s = ut + 0.5at^2
                    ny = (uy * t) + (0.5 * (g) * Math.pow(t, 2));
                     
                    // Apply the positions 
                    $(self).css({'bottom' : (ny)+'px', 'left' : (nx)+'px'});
                     
                    // Increase the time by 0.10
                    t = t + 0.10;
                     
                    // If the time is greater than the total time clear the interval
                    if(t > totalt) {
                         
                        clicked = false;
                        first = true;
                         
                         
                        $('.clipped-box').css({'top' : '-1000px', 'transition' : 'none'});
                        $(self).css({'left' : '0', 'bottom' : '0', 'opacity' : '1', 'transition' : 'none', 'transform' : 'none'});
                     
                                 
                        // Finally clear the interval
                        clearInterval(z);
                     
                    }
                     
                }, 10); // Run this interval every 10ms. Changing this will change the pace of the animation
         
            });
             
        }
     
    });        
    r = setInterval(function() {
        // This is a bit rough but it does the job
        if(first === true) {
            // I've just put this in so the deleted box will come down again after its been clicked.
            // That way you can keep pressing delete.          
            $('.clipped-box').css({'top' : '0', 'transition' : ''});
            $('.clipped-box p').css({'opacity' : '1', 'transition' : '', 'background-color' : ''});
                         
            $('.content').css({'display' : 'block'});
                 
            first = false;
             
        }
                 
    }, 300);
});
标签:css3点击爆炸特效
PREVIOUS:MySQL数据库的启动/连接/断开与停止
NEXT:css3图片一道闪光划过特效代码
  • 清除浮动
  • loading
  • 排行榜
  • 兼容IE6
  • css3
  • CSS
  • 图片放大
  • CSS3效果
  • 点击爆炸
  • 纯css3
  • 旋转放大
  • 跟踪状态
  • 小技巧
  • css3特效
  • 自动换行
  • 更新
  • HTML
  • 边框
  • 特效
  • 动画特效
  • 特效代码
  • 网页
  • img图片最大宽
  • 360度旋转
  • 透明度
  • 移动
  • 边框阴影
  • 加载
  • 图片闪光划过
  • 省略号
  • 放大
  • TAB
  • 选项卡
  • 物流快递
  • svg
最新模板
  • 创建账户表单页面模板

    这是一套创建账户表单页面模板是一款简单好看的网站表单注册网站模板下载

  • 口腔医学研究所网站模板

    这是一套美容美颜化妆品公司网站模板是一款蓝色大气医疗口腔网站模板下载

  • 美容美颜化妆品公司网站模板

    这是一套美容美颜化妆品公司网站模板是一款大气单页网站模板下载

  • 蓝色探索世界旅游网站模板

    这是一套蓝色探索世界旅游网站模板里面包含8个子页面,适合旅游公司网站模板下载

  • 教育机构学校HTML5模板

    这是一套教育机构学校HTML5模板是一款基于Bootstrap制作的教育类网站模板下载

热门推荐
  • 1absolute定位css元素居中的两种方法
  • 2html网页引入svg
  • 3如何网页中引用字体文件
  • 4CSS显示不同颜色数字的排行榜
  • 5CSS英文字符自动换行
  • 6CSS图片透明度
  • 7css实现div边框阴影
  • 8css设置div边框
  • 9纯css3实现加载等待loading动画特效代码
  • 10纯css3实现的物流快递跟踪状态更新css3特效
  • 11CSS清除浮动方法汇总
  • 12CSS3制作漂亮TAB选项卡
  • 13css3图片一道闪光划过特效代码
  • 14css3点击爆炸下落的特效代码
  • 15HTML+css图片放大特效代码
百宝箱
  • CSS压缩格式化

    CSS压缩

  • html格式化

    html格式化

  • 繁体字转换器

    繁体字转换

  • JSON检验

    JSON检验

  • MD5加密

    MD5加密

  • css3动画

    css3动画

© 2016-2021 代码库关于我们网站导航网站地图皖ICP备14004357号
代码库