HTML5网页设计

图片效果

鼠标经过小图出现大图提示效果

时间:2014-11-28 17:40来源:未知作者:点击:
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdhtml xmlns=http://www.w3.org/1999/xhtml xml:lang=enheadmeta http-equiv=Content-Type content=text/html;charset=UTF-8 /title鼠

<!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" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>鼠标经过小图出现大图提示效果</title>
</head>
<body>
<title></title>
<style type="text/css">
#demo{overflow:hidden;width:120px;text-align:center;padding:10px;} 
 #demo img{border:none;width:100px;height:100px;border:5px solid #f4f4f4} 
 #enlarge_images{position:absolute;display:none;z-index:2;border:5px solid #f4f4f4}</style>
<div id="demo" style="overflow:hidden;width:120px;text-align:center;padding:10px">
	<img _fcksavedurl="http://www.shejicool.com/uploads/allimg/201105/143S212A-0.jpg" src="http://www.shejicool.com/uploads/allimg/201105/143S212A-0.jpg" /></div>
<div id="enlarge_images">
	&nbsp;</div>
<script>
var demo = document.getElementById("demo");
var gg = demo.getElementsByTagName("img");
var ei = document.getElementById("enlarge_images");
for(i=0; i<gg.length; i++){
	var ts = gg[i];
	ts.onmousemove = function(event){
		event = event || window.event;
		ei.style.display = "block";
		ei.innerHTML = '<img src="' + this.src + '" />';
		ei.style.top  = document.body.scrollTop + event.clientY + 10 + "px";
		ei.style.left = document.body.scrollLeft + event.clientX + 10 + "px";
	}
	ts.onmouseout = function(){
		ei.innerHTML = "";
		ei.style.display = "none";
	}
	ts.onclick = function(){
		window.open( this.src );
	}
}
</script><br />
<p style="margin-top:200px;color:#555555;">
	此资源来自[<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com" target="_blank">设计酷</a>],更多实用资源请访问<a _fcksavedurl="http://www.shejicool.com" href="http://www.shejicool.com" target="_blank">www.shejicool.com</a></p>
</body>
</html>
上一篇:上一篇:JS实现图片按比例等比缩小 上一篇:下一篇:鼠标可控制上下图片滚动代码
阅完本篇文章?您还可以: 收藏本文 文章挑错 朋友推荐