純CSS Lightbox效果_Div+CSS教程

      編輯Tag賺U幣
      教程Tag:CSSLightbox添加

      網絡上有很多js版本的lightbox效果介紹。不過都下載一個lightbox的js小則幾十K,大則上百K。如果你只是需要一個類似Lightbox的效果,這種百分之百純CSS制造,不含js的辦法到可以試試。原理很簡單,看看就應該民明白了。

      本文來源與模板無憂_www.wf0088.com 模板無憂_www.wf0088.com

       

      CSS部分:

      <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>

      HTML部分:

      <body>
              <p>This is the main content. To display a lightbox click <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a></p>
              <div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
              <div id="fade" class="black_overlay"></div>
      </body>

      來源:模板無憂//所屬分類:Div+CSS教程/更新時間:2012-08-06
      相關Div+CSS教程