Thursday, May 27, 2010

CSS based lightbox takes seconds to implement

If you want to implement lightbox in short time with less effort and compatible with FF and IE here you go. Copy-paste below html in your page replaces the content and you are done.

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
<style type="text/css">
.black_overlay{
display: none;
position: fixed;
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;
font-family: Verdana;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
border: 16px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
font-size:small;
}
#screenshot {
BORDER-BOTTOM: #ccc 1px solid;
POSITION: absolute;
BORDER-LEFT: #ccc 1px solid;
PADDING-BOTTOM: 5px;
PADDING-LEFT: 5px;
PADDING-RIGHT: 5px;
DISPLAY: none;
BACKGROUND: #333;
COLOR: #fff;
BORDER-TOP: #ccc 1px solid;
BORDER-RIGHT: #ccc 1px solid;
PADDING-TOP: 5px
}
</style>
</head>
<body>
<div>
this is body content

<input type="button" value="Click here to load lightbox" onclick="document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'" />
</div>
<div id="light" class="white_content">
<a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">
Close</a><br />
<br />
<br />
<div id="container" runat="server">
Put your lightbox content over here
</div>
</div>
<div id="fade" runat="server" class="black_overlay">
</div>
</body>
</html>

This will look something like below:

No comments:

Post a Comment