【求助】如何实现一类类似弹框的动态效果
求教如何一个动态效果。
参见“http://www.xiami.com/album/162557821”。当我点击左上那张封面图片的时候,会弹出一张大图,而原来的页面加上阴影了。当单机阴影部分或者大图时,又回到了原来页面。如何实现这个效果呢?
这是我们作业的一部分,还挺急的,我现在是希望有个按钮button,单击一下,就出现上面类似的效果,但是上例显示图片的部分,我希望能够自己加一些别的代码,显示别的内容,而不只是一张图。 求教如何实现?能贴一下javascript的代码给我么?谢谢了!
<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
 <form><input type="button" id="achievement" value="Achievement"></form>
<script>
//实现上述描述效果的代码
</script>
</body>
</html>
              
                  JavaScript
              
------解决方案--------------------<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
	function init(){
		var img=document.images[0];
		img.onclick=function(){
			var div=addScreen();
			addImage(div);
		}
	}
	function addScreen(){
		var div=document.createElement("div");
		var style={
			'position':'absolute',
			'left':'0px',
			'top':'0px',
			'width':'100%',
			'height':'100%',
			'opacity':'.5',
			'filter':'alpha(opacity=50)',
			'backgroundColor':'black'
		}
		for(var i in style){
			div.style[i]=style[i];
		}
		document.body.appendChild(div);
		return div;
	}
	function addImage(div){
		var img=document.createElement("img");
		img.setAttribute("src",'a.jpg');
		var style={
			'position':'absolute',
			'left':'100px',
			'height':'400px',
			'top':'100px',
			'width':'400px'
		};
		for(var i in style){
			img.style[i]=style[i];
		}
		div.onclick=function(){
			removeElement(div,img);
		}
		img.onclick=function(){
			removeElement(div,img);
		}
		document.body.appendChild(img);
	}
	function removeElement(div,img){
		var pd=div.parentNode;
		var pi=img.parentNode;
		pd.removeChild(div);
		pi.removeChild(img);
	}
	window.onload=init;
</script>
</head>
<body>
<img src="a.jpg" />
</body>
</html>
类似这样试试
------解决方案--------------------http://leandrovieira.com/projects/jquery/lightbox/
以前用过这个,这用了jQuery插件,你从上面那个网址去下载
------解决方案--------------------
                该回复于2013-04-17 17:12:57被管理员删除