<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<title>利用JS实现文字的聚合动画效果</title>
<style>
.boxWrap1{width: 160px;height: 417px;position: relative;margin:0px auto;}
.boxWrap1 img{width: 100%;}
.boxWrap1 div{background: url(http://itakeo.com/wpimg/2_1.png) no-repeat;background-size: 160px auto; position: absolute; left: 0px;top: 0px;
}
.boxWrap1.set div{ opacity: 1!important;
transform:perspective(800px) translate3d(0px,0px,0px) rotate(0deg) scale(1)!important;
-moz-transform:perspective(800px) translate3d(0px,0px,0px) rotate(0deg) scale(1)!important;
-webkit-transform:perspective(800px) translate3d(0px,0px,0px) rotate(0deg) scale(1)!important;
}
.boxSiteWrap{ width: 100%;overflow: hidden;height: auto; background: #000;padding: 140px 0}
.boxSiteWrap button{cursor:pointer;display: block;font-size: 16px; width: 140px;height: 40px; background: #fff;color: #000;border:none;margin:30px auto;}
</style>
</head> <body>
<div class="boxSiteWrap">
<div class="boxWrap1"></div>
<button>重新加载</button>
</div> <script>
window.addEventListener('load',function(){
;(function(){
function init(){
var box = document.querySelector('.boxWrap1')
var c=4,r=8;
var w = box.offsetWidth/c,h = box.offsetHeight/r;
for(var i=0;i<r;i++){
for(var j=0;j<c;j++) {
var _div=document.createElement('div');
var _left = j * w,_top = i * h;
_div.style.cssText = 'width:'+w+'px;height:'+h+'px;left:'+_left+'px;top:'+_top+'px; opacity:0;background-position:'+(-_left) + 'px ' + (-_top) + 'px';
_div.style.transition = _div.style.MozTransition = _div.style.WebkitTransition = 'all '+ Random(1,1.8) +'s ease';
_div.style.transform = _div.style.MozTransform = _div.style.WebkitTransform = 'perspective(800px) translate3d('+Random(-200,200)+'px, '+Random(-200,200)+'px,300px) rotate('+Random(-90,90)+'deg) scale('+ Random(0,2) +')'
box.appendChild(_div);
};
};
setTimeout(function(){
box.classList.add('set')
},100);
function Random(start,end){
return Math.random()*(end-start)+start;
};
};
init();
var flag = true;
document.querySelector('button').onclick = function(){
if(flag){
document.querySelector('.boxWrap1').classList.remove('set')
setTimeout(function(){
document.querySelector('.boxWrap1').innerHTML = '';
init();
flag = true;
},1200);
flag = false;
};
};
})();
});
</script>
</body>
</html>

demo:https://controllerone.github.io/demo/piece.html

原文链接:http://itakeo.com/blog/2015/12/14/imgcover/?none=123

js图片碎片效果(移动端也适用)的更多相关文章

  1. js图片放大效果

    实现购物网站里的图片放大效果,jqzoom很好用.今天才接触它,很快就上手了.看了一个示例,在放大图像上方貌似有水印,后经排查,原来是图片的标题,然后设置title为false,搞定.

  2. js 图片切换效果

    效果如下: 代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type&quo ...

  3. JS图片切换效果

    源地址:http://www.codefans.net/jscss/code/4699.shtml <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1 ...

  4. JS图片宽度自适应移动端

    $(function(){ $("#d-intro").find("img").each(function () {                $(this ...

  5. JavaScript仿百度图片浏览效果(转载)

    转载来源:https://www.jb51.net/article/98030.htm 这是一个非常好的案例,然而jquery的时代正在徐徐关闭. 当你调整浏览器宽高,你会发现它不是自适应的.当你想把 ...

  6. JS实现有点炫的图片展示效果-图片解体和组合

    经过4个月的努力学习,迎来了进入市场的最后一个学习项目.自己模仿了一个图片展示效果,用在了项目中,感觉挺炫的.在这里分享一下,希望大家喜欢~! bomb-showImg : 在线演示http://ru ...

  7. jquery简单的图片切换效果,支持pc端、移动端的banner图片切换开发

    详细内容请点击 无意中看见了两年前写的一个图片切换,那会儿刚刚学习网页制作,可以说是我的第一个处女座的jquery图片切换效果.无聊之余对它的宽度稍稍做了一下修改,变成了支持pc端.手机端全屏的ban ...

  8. js鼠标滚轮滚动图片切换效果

    效果体验网址:http://keleyi.com/keleyi/phtml/image/12.htm HTML文件代码: <!DOCTYPE html PUBLIC "-//W3C// ...

  9. [读码][js,css3]能感知鼠标方向的图片遮罩效果

    效果图: 无意间看到过去流行的一个效果:[能感知鼠标方向的图片遮罩效果]近来不忙,就仔细的看了一看看到后来发现,网上有好多版本,谁是原著者似乎已经无法考证.读码就要读比较全面的,读像是原著的代码.代码 ...

随机推荐

  1. Python对象和类

    Python 里的所有数据都是以对象形式存在的,对象是类的实例. 定义类(class) 使用class来定义一个类. 比如,定义一个cat类,如下: class Cat(): def __init__ ...

  2. Aria2 使用

    没错,又是受够了迅雷.旋风的各种奇葩减速(哥哥我还买了了VIP!),IDM 对协议支持又太少还有事没事提示你不是正版三天两头闹着要更新.于是我想起来之前看到过的 Aria2,虽然之前也只是略有耳闻,但 ...

  3. 廖雪峰Java15JDBC编程-3JDBC接口-4JDBC事务

    1 数据库事务:Transaction 1.1 定义 若干SQL语句构成的一个操作序列 要么全部执行成功 要么全部执行不成功 1.2 数据库事务具有ACID特性: Atomicity:原子性 一个事务 ...

  4. 莫烦PyTorch学习笔记(三)——激励函数

    1. sigmod函数 函数公式和图表如下图     在sigmod函数中我们可以看到,其输出是在(0,1)这个开区间内,这点很有意思,可以联想到概率,但是严格意义上讲,不要当成概率.sigmod函数 ...

  5. 移动端自定义键盘的vue组件 ----keyboard

    <style scoped lang="less"> .keyboard { /* height: 250px; */ width: 100%; position: f ...

  6. ssh 与服务器保持连接

    直接改客户端,服务器端不应该更改. sudo vi /etc/ssh/ssh_config # 或 ~/.ssh/config TCPKeepAlive=yes # Client每隔 60 秒发送一次 ...

  7. 数论专场 Day9 部分题解

    // 2019年西电暑期集训 // [7月9日]基础数论:https://cn.vjudge.net/contest/309097 A - Visible Lattice Points 题目大意: 平 ...

  8. Nmap扫描原理(下)

    转自:https://blog.csdn.net/qq_34398519/article/details/89055999 3     Nmap高级用法 3.1    防火墙/IDS规避 防火墙与ID ...

  9. 新增的Java MapReduce API

    http://book.51cto.com/art/201106/269647.htm Hadoop的版本0.20.0包含有一个新的 Java MapReduce API,有时也称为"上下文 ...

  10. SQLServer 2008 的数据库日志清理

    -- SQLServer 2008 的数据库日志清理 ,与 Sql2000 或 2005 的方法不一样,需要采用 下面的sql来清理 USE [master] GO ALTER DATABASE [数 ...