Page Widget How to - Create lightbox/dialog box effect








Question

We would like to know how to create lightbox/dialog box effect.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#lightbox {<!--   www.j  av a  2  s  . co  m-->
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #000;
  opacity: .6;
}

#main {
  position: relative;
  background-color: #fff;
  z-index: 1;
}
</style>
</head>
<body>
  <div id="main">Lorem ipsum, my opactiy is not affected</div>
  <p>My opactiy is affected</p>
  <div id="lightbox"></div>
</body>
</html>

The code above is rendered as follows: