js钢琴按钮波浪式图片排列效果代码分享
作者:bea
本文实例讲述了js钢琴按钮波浪式图片排列效果。分享给大家供大家参考。具体如下: 这是一款基于javascript实现的钢琴按钮波浪式图片排列效果,鼠标在图片列表上移动,当前图片高亮显示,以此为根基点,周围的图片逐渐变小,所以有种手指划过钢琴键盘的感觉。 运行效果图: -------------------查看效果------------------- 小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。 注意:图片的alt属性不能缺少,否则将导致效果失败。 为大家分享的
本文实例讲述了js钢琴按钮波浪式图片排列效果。分享给大家供大家参考。具体如下: 这是一款基于javascript实现的钢琴按钮波浪式图片排列效果,鼠标在图片列表上移动,当前图片高亮显示,以此为根基点,周围的图片逐渐变小,所以有种手指划过钢琴键盘的感觉。 运行效果图: -------------------查看效果-------------------
小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。
注意:图片的alt属性不能缺少,否则将导致效果失败。 为大家分享的js钢琴按钮波浪式图片排列效果代码如下
head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js钢琴按钮波浪式图片排列效果</title>
<style>
#bookrack { width: 1200px; margin:100px auto; overflow:hidden;}
#bookrack a { text-align: center; text-decoration: none; font-size: 12px; }
#bookrack span { display: none; position: absolute; color: #fff; background-color: #000; 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>
<!--代码部分begin-->
<div id="bookrack">
<a href="#" title=""><img src="images/2.jpg" alt="" /></a>
<a href="#" title=""><img src="images/3.jpg" alt="" /></a>
<a href="#" title=""><img src="images/4.jpg" alt="" /></a>
<a href="#" title=""><img src="images/5.jpg" alt="" /></a>
<a href="#" title=""><img src="images/6.jpg" alt="" /></a>
<a href="#" title=""><img src="images/7.jpg" alt="" /></a>
<a href="#" title=""><img src="images/8.jpg" alt="" /></a>
<a href="#" title=""><img src="images/2.jpg" alt="" /></a>
<a href="#" title=""><img src="images/3.jpg" alt="" /></a>
<a href="#" title=""><img src="images/4.jpg" alt="" /></a>
<a href="#" title=""><img src="images/5.jpg" alt="" /></a>
<a href="#" title=""><img src="images/6.jpg" alt="" /></a>
<a href="#" title=""><img src="images/7.jpg" alt="" /></a>
<a href="#" title=""><img src="images/8.jpg" alt="" /></a>
</div>
<script>
var Bookrack = function(a, b, c, e) {
this.scale = e || 0.1;
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");
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>
<!--代码部分end-->
</body>
</html>
以上就是为大家分享的js钢琴按钮波浪式图片排列效果代码,希望大家可以喜欢。
有用 | 无用
小提示:浏览器中如果不能正常运行,可以尝试切换浏览模式。
注意:图片的alt属性不能缺少,否则将导致效果失败。 为大家分享的js钢琴按钮波浪式图片排列效果代码如下
head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js钢琴按钮波浪式图片排列效果</title>
<style>
#bookrack { width: 1200px; margin:100px auto; overflow:hidden;}
#bookrack a { text-align: center; text-decoration: none; font-size: 12px; }
#bookrack span { display: none; position: absolute; color: #fff; background-color: #000; 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>
<!--代码部分begin-->
<div id="bookrack">
<a href="#" title=""><img src="images/2.jpg" alt="" /></a>
<a href="#" title=""><img src="images/3.jpg" alt="" /></a>
<a href="#" title=""><img src="images/4.jpg" alt="" /></a>
<a href="#" title=""><img src="images/5.jpg" alt="" /></a>
<a href="#" title=""><img src="images/6.jpg" alt="" /></a>
<a href="#" title=""><img src="images/7.jpg" alt="" /></a>
<a href="#" title=""><img src="images/8.jpg" alt="" /></a>
<a href="#" title=""><img src="images/2.jpg" alt="" /></a>
<a href="#" title=""><img src="images/3.jpg" alt="" /></a>
<a href="#" title=""><img src="images/4.jpg" alt="" /></a>
<a href="#" title=""><img src="images/5.jpg" alt="" /></a>
<a href="#" title=""><img src="images/6.jpg" alt="" /></a>
<a href="#" title=""><img src="images/7.jpg" alt="" /></a>
<a href="#" title=""><img src="images/8.jpg" alt="" /></a>
</div>
<script>
var Bookrack = function(a, b, c, e) {
this.scale = e || 0.1;
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");
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>
<!--代码部分end-->
</body>
</html>
以上就是为大家分享的js钢琴按钮波浪式图片排列效果代码,希望大家可以喜欢。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- 纯javascript实现分页(两种方法)
- jquery实现LED广告牌旋转系统图片切换效果代码分享
- jquery实现图片水平滚动效果代码分享
- jquery validate和jquery form 插件组合实现验证表单后AJAX提交
- jquery实现漂亮的二级下拉菜单代码
- js+css实现的圆角边框TAB选项卡滑动门代码分享(2款)
- jQuery实现的简洁下拉菜单导航效果代码
- jQuery网页选项卡插件rTabs用法实例分析
- jQuery实现带滑动条的菜单效果代码
- js支持键盘控制的左右切换立体式图片轮播效果代码分享
- js鼠标点击图片切换效果代码分享
- jQuery实现的网页竖向菜单效果代码
- js控制多图左右滚动切换效果代码分享
- 简介alert()与console.log()的不同
- jQuery左右滚动支持图片放大缩略图图片轮播代码分享
- JS根据key值获取URL中的参数值及把URL的参数转换成json对象
- jquery实现的横向二级导航效果代码
- jQuery三级下拉列表导航菜单代码分享
- jquery用ajax方式从后台获取json数据后如何将内容填充到下拉列表