当前位置:文档之家› 实现点击小图查看大图方式

实现点击小图查看大图方式

把以下代码复制到项目上即可实现点击小图看大图(原图),把width和height调整可设置显示界面大小。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>纯CSS Lightbox效果(无需JS)</title>
<style>
body{font-size:11px; font-family:Verdana, Arial, Helvetica, sans-serif;}
a{color:#000; text-decoration:none;}
.img{border:0px;}
.black_overlay{
display: none;
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.white_content {
<--设置大图属性-->
display: none;
position: absolute;
top: 15%;
left: 25%;
width: 632px;
height: 445px;
border: 16px solid #FFF;
border-bottom:none;
background-color: white;
z-index:1002;
overflow: auto;
}
</style>
</head>
<body>
<p><a href="#"onclick="document.getElementById('light').style.display ='block';document.getElementById('fade').style.display='block'"><img src ="/lab/lightbox_withoutjs/small.jpg"/></a></p>
<!--小图-->
<!--大图可放任意位置,都在中间显示-->
<div id="light" class="white_content"><img src
="/lab/lightbox_withoutjs/big.jpg"/>
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display
='none';document.getElementById('fade').style.display='none'">关闭</a></div> <div id="fade" class="black_overlay"></div>
</body>
</html>。

相关主题