圖片翻轉(zhuǎn)效果具體實現(xiàn)代碼
更新時間:2014年01月09日 17:02:51 作者:
想必大家對圖片翻轉(zhuǎn)效果都有所了解吧,其實很容易實現(xiàn)的,下面有個不錯的示例,喜歡的朋友可以參考下
以下為程序代碼:
<!DOCTYPE html />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>圖片翻轉(zhuǎn)效果</title>
<style type="text/css">
.box {overflow:hidden;position:relative;}
.txt {width:100%;height:100%;background:#f51146;font-size:12px;position:absolute;top:-100%;color:white;
text-align:center;filter:alpha(Opacity=80);-moz-opacity:0.8;opacity:0.8;}
#b1 {background:url(http://biyuan.tk/u/upload/201310221457326875.jpg);width:232px;height:232px;}
#b2 {background:url(http://biyuan.tk/u/upload/201310221457486875.jpg);width:110px;height:110px;}
#b3 {background:url(http://biyuan.tk/u/upload/201310221458149843.jpg);width:110px;height:110px;}
</style>
</head>
<body>
<div id="obj">
<div class="box" id="b1"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
<div class="box" id="b2"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
<div class="box" id="b3"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
</div>
<script type="text/javascript">
function Show(o, s, v){
clearInterval(Show.prototype["a" + v]);
Show.prototype["a" + v] = setInterval(function(){
if(s == -1) {
if(o.offsetTop <= -o.parentNode.offsetHeight) {
o.style.top = -o.parentNode.offsetHeight + "px";
return clearInterval(Show.prototype["a" + v]);
}
} else {
if(o.offsetTop >= -10) {
o.style.top = 0;
return clearInterval(Show.prototype["a" + v]);
}
}
o.style.top = (o.offsetTop * 1 + 10 * s) + "px";
}, 10);
}
var igs = document.getElementById('obj').getElementsByTagName("div");
for(var i = 0; i < igs.length; i ++) {
if(igs[i].className == "box") {
(function(x){
igs[x].onmouseover = function(){
Show(this.childNodes[0], 1, x);
this.onmouseout = function() {
Show(this.childNodes[0], -1, x);
}
}
})(i);
}
}
</script>
</body>
</html>
效果預(yù)覽:http://biyuan.tk/u/upload/201310221500310000.html
復(fù)制代碼 代碼如下:
<!DOCTYPE html />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>圖片翻轉(zhuǎn)效果</title>
<style type="text/css">
.box {overflow:hidden;position:relative;}
.txt {width:100%;height:100%;background:#f51146;font-size:12px;position:absolute;top:-100%;color:white;
text-align:center;filter:alpha(Opacity=80);-moz-opacity:0.8;opacity:0.8;}
#b1 {background:url(http://biyuan.tk/u/upload/201310221457326875.jpg);width:232px;height:232px;}
#b2 {background:url(http://biyuan.tk/u/upload/201310221457486875.jpg);width:110px;height:110px;}
#b3 {background:url(http://biyuan.tk/u/upload/201310221458149843.jpg);width:110px;height:110px;}
</style>
</head>
<body>
<div id="obj">
<div class="box" id="b1"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
<div class="box" id="b2"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
<div class="box" id="b3"><div class="txt">文字說明<br />文字說明</br />文字</div></div>
</div>
<script type="text/javascript">
function Show(o, s, v){
clearInterval(Show.prototype["a" + v]);
Show.prototype["a" + v] = setInterval(function(){
if(s == -1) {
if(o.offsetTop <= -o.parentNode.offsetHeight) {
o.style.top = -o.parentNode.offsetHeight + "px";
return clearInterval(Show.prototype["a" + v]);
}
} else {
if(o.offsetTop >= -10) {
o.style.top = 0;
return clearInterval(Show.prototype["a" + v]);
}
}
o.style.top = (o.offsetTop * 1 + 10 * s) + "px";
}, 10);
}
var igs = document.getElementById('obj').getElementsByTagName("div");
for(var i = 0; i < igs.length; i ++) {
if(igs[i].className == "box") {
(function(x){
igs[x].onmouseover = function(){
Show(this.childNodes[0], 1, x);
this.onmouseout = function() {
Show(this.childNodes[0], -1, x);
}
}
})(i);
}
}
</script>
</body>
</html>
效果預(yù)覽:http://biyuan.tk/u/upload/201310221500310000.html
相關(guān)文章
JavaScript遍歷table表格中的某行某列并打印其值
這篇文章主要介紹了JavaScript遍歷table表格中的某行某列并打印其值,需要的朋友可以參考下2014-07-07js實現(xiàn)鍵盤操作實現(xiàn)div的移動或改變的原理及代碼
實現(xiàn)鍵盤操作實現(xiàn)div的移動,最關(guān)鍵的一點:獲取div對象,下面有個不錯的示例,大家可以參考下2014-06-06javascript設(shè)計模式 – 迭代器模式原理與用法實例分析
這篇文章主要介紹了javascript設(shè)計模式 – 迭代器模式原理與用法,結(jié)合實例形式分析了javascript迭代器模式相關(guān)概念、原理、用法及操作注意事項,需要的朋友可以參考下2020-04-04layui switch 開關(guān)監(jiān)聽 彈出確定狀態(tài)轉(zhuǎn)換的例子
今天小編就為大家分享一篇layui switch 開關(guān)監(jiān)聽 彈出確定狀態(tài)轉(zhuǎn)換的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09return false,對阻止事件默認(rèn)動作的一些測試代碼
很明顯我們每個函數(shù)都返回false,如果返回值可以阻止事件默認(rèn)動作,那么文本框?qū)o法輸入任何內(nèi)容。 看下面我測試的結(jié)果,注意紅的部分。2010-11-11