文字与图片互相切换js效果
2013-03-28 16:48
253 查看
<!DOCTYPE html>
<html>
<head>
<style>
a.blockA{display:block;width:200px;height:20px;overflow:hidden;white-space: nowrap;position: relative;}
a.blockA div{display:block;width:100%;height:100%;background-color:white;position: absolute;top:0px;left:0px;}
a.blockA img.bizLogo{width:10%;height:100%;}
a.blockA img.bizTel{width:89%;height:100%;}
</style>
</head>
<body>
<script src="http://icon.chinahrd.net/js/common.js"></script>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<script>
(function() {
var taner, prer;
var setTran = function(per, obj) {
if (_.isIe) {
obj.style.filter = 'alpha(opacity=' + per + ')';
} else {
obj.style.opacity = per / 100;
}
};
var clear = function() {
clearInterval(taner);
}
_.each(_('&test'), function(_this) {
_this.onmouseover = function () {
clear();
var per = 100;
var obj = _.lastHtml(this);
prer && setTran(100, prer);
prer = obj;
setTran(per, obj);
taner = setInterval(function(){
if (per-- < 0) {
clear();
return;
} else {
setTran(per, obj);
}
}, 10);
}
_this.onmouseout = function () {
clear();
var per = 0;
var obj = _.lastHtml(this);
setTran(per, obj);
taner = setInterval(function(){
if (per++ > 100) {
clear();
return;
} else {
setTran(per, obj);
}
}, 10);
}
});
})();
</script>
</body>
</html>
效果是透明成0显示图片,移开恢复不透明
![](http://img.bimg.126.net/photo/BibhkIkfCGC_u2thBlTLAg==/3725884266735820930.jpg)
<html>
<head>
<style>
a.blockA{display:block;width:200px;height:20px;overflow:hidden;white-space: nowrap;position: relative;}
a.blockA div{display:block;width:100%;height:100%;background-color:white;position: absolute;top:0px;left:0px;}
a.blockA img.bizLogo{width:10%;height:100%;}
a.blockA img.bizTel{width:89%;height:100%;}
</style>
</head>
<body>
<script src="http://icon.chinahrd.net/js/common.js"></script>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<a class="blockA" name="test">
<img src="http://icon.chinahrd.net/image/guanliren.jpg" class="bizLogo"/>
<img src="http://icon.chinahrd.net/image/mag_1.jpg" class="bizTel"/>
<div>标题标题标题标题标题</div>
</a>
<script>
(function() {
var taner, prer;
var setTran = function(per, obj) {
if (_.isIe) {
obj.style.filter = 'alpha(opacity=' + per + ')';
} else {
obj.style.opacity = per / 100;
}
};
var clear = function() {
clearInterval(taner);
}
_.each(_('&test'), function(_this) {
_this.onmouseover = function () {
clear();
var per = 100;
var obj = _.lastHtml(this);
prer && setTran(100, prer);
prer = obj;
setTran(per, obj);
taner = setInterval(function(){
if (per-- < 0) {
clear();
return;
} else {
setTran(per, obj);
}
}, 10);
}
_this.onmouseout = function () {
clear();
var per = 0;
var obj = _.lastHtml(this);
setTran(per, obj);
taner = setInterval(function(){
if (per++ > 100) {
clear();
return;
} else {
setTran(per, obj);
}
}, 10);
}
});
})();
</script>
</body>
</html>
效果是透明成0显示图片,移开恢复不透明
![](http://img.bimg.126.net/photo/BibhkIkfCGC_u2thBlTLAg==/3725884266735820930.jpg)
![](http://img.bimg.126.net/photo/jR0cwORVSEiOVxfelfs0Iw==/3725884266735820931.jpg)
相关文章推荐
- JS实现的文字与图片定时切换效果代码
- js+div实现文字滚动和图片切换效果代码
- js+div实现文字滚动和图片切换效果代码
- JS实现的文字与图片定时切换效果代码
- JS+CSS代码简洁的无间断文字向上滚动切换效果
- js实现百度联盟中一款不错的图片切换效果完整实例
- 【荐】JS+CSS防FLASH效果带倒影的图片切换效果代码
- js实现单张图片平移切换效果
- Flexslider图片轮播、文字图片相结合滑动切换效果
- html+css+js(+JQuery)制作扑克牌图片切换效果
- jq实现左侧显示图片右侧文字滑动切换效果
- js带缩略图的图片切换效果
- js 图片切换效果
- js图片自动切换效果处理代码
- 多张图片切换效果js代码
- css图片切换效果代码[不用js]
- 腾讯首页js图片切换效果
- 一款在论坛上看到的JS封装的随机过渡方式的图片切换效果
- 原生JS实现隐藏显示图片 JS实现点击切换图片效果
- CSS+JS控制遮罩效果的TAB及焦点图片切换