码迷,mamicode.com
首页 > Web开发 > 详细

原生JS写的一个书架式的图片缩放滚动展示特效代码

时间:2015-04-27 12:40:25      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:

<!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" lang="en">
<head>
    <title>demo 石家庄展柜厂|石家庄非标门</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="author" content="xiaomiqiang@gmail.com" />
    <style type="text/css">
#bookrack { width: 600px; margin: auto; } #bookrack a { text-align: center; text-decoration: none; font-size: 12px; } #bookrack span { display: none; position: absolute; color: #fff; background: #000000; background: rgba(0, 0, 0, 0.5); padding: 5px; top: 30px; left: 0; } #bookrack span big { color: red; font-size: 14px; } #bookrack img { width: 100%; height: 100%; display: block; border: 0; }
    </style>
</head>
<body>
<div id="bookrack">
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t1.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t2.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t3.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t4.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t5.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t6.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t7.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t8.gif" alt="阿里西西" /></a>
    <a href="http://js.alixixi.com" title="网页特效"><img src="http://www.alixixi.cn/images/index/t9.gif" alt="阿里西西" /></a>
</div>

<script type="text/javascript">
var Bookrack=function(a,b,c,e){this.scale=e||0.4;this.x=b||120;this.y=c||160;this.border=2;this.init(a);this.exec(Math.ceil(Math.random()*this.imgs.length))};
Bookrack.prototype={init:function(a){this.width=a.clientWidth-2*this.x*this.scale;a.style.position="relative";a.style.height=this.y+"px";this.imgs=a.getElementsByTagName("a");var b=this,c=document.createElement("span"),e,d;this.each(function(a,g){a.style.position="absolute";a.style.bottom="0";a.style.border=this.border+"px solid gray";a.style.left=this.width*(g/this.imgs.length)+2*this.border+"px";a.setAttribute("dir",g);d=a.getElementsByTagName("img")[0].getAttribute("alt").split("|");e=c.cloneNode(!0);
e.innerHTML=a.getAttribute("title")+"/"+d[0]+"/\u7b2c"+d[1]+"\u7ae0/\u7b2c<big>"+d[2]+"</big>\u9875";a.appendChild(e);a.onmouseover=function(){b.exec(this.getAttribute("dir"))}})},each:function(a){for(var b=0,c;c=this.imgs[b++];)a.call(this,c,b,this.imgs.length)},color:function(a){a=(~~(255*a)).toString(16);2>a.length&&(a="0"+a);a=a.substr(0,2);return"#"+a+a+a},exec:function(a){this.each(function(b,c,e,d,f){b.getElementsByTagName("span")[0].style.display="none";c==a&&(b.getElementsByTagName("span")[0].style.display=
"block");d=Math.min(c/a,a/c);f=Math.sin(90*(Math.PI/180)*d)*(1-this.scale);b.style.zIndex=Math.ceil(1E4*f);b.style.borderColor=this.color(f+this.scale);b.style.width=this.x*(f+this.scale)-2*this.border+"px";b.style.height=this.y*(f+this.scale)-2*this.border+"px";b.style.marginLeft=this.x*f/-2+"px"})}};
    new Bookrack(document.getElementById(bookrack), 120, 160);
</script>
</body>
</html>

 

原生JS写的一个书架式的图片缩放滚动展示特效代码

标签:

原文地址:http://www.cnblogs.com/zhaozzm/p/4459544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!