查看完整版本: 纯CSS制作的网页中的lightbox效果

迷失的亲 2007-10-29 16:05

纯CSS制作的网页中的lightbox效果

“Lightbox”是一个别致且易用的图片显示效果,它可以使图片直接呈现在当前页面之上而不用转到新的窗口。lightbox效果网络上有很多js版本的介绍。不过都下载一个lightbox的js小则几十K,大则上百K。如果你只是需要一个类似Lightbox的效果,这种百分之百纯CSS制造,不含js的办法倒是可以试试。[code]<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
B axKA <html> tqT+hjHH ^,L
    <head> lF C TFs
        <title>纯CSS Lightbox效果</title>
6aBm@YEX.]VE ~         <style> X%FA4U(jD JI
        .black_overlay{
I;g eT y5RZD!Sf             display: none; +N7xSc#C
            position: absolute; ^2H8uT"z:^
            top: 0%; *wy,I~g Q)U8u
            left: 0%;
*bb|'E1|             width: 100%; *F*yRd3y#D
            height: 100%;
P+}Ku)^w             background-color: black;
(Q&arC*j             z-index:1001; f%^/_+]x
            -moz-opacity: 0.8; ?"|5S5Ufh iw$R d
            opacity:.80;
gP"p+{R zB*e2Ul             filter: alpha(opacity=80); G LX6Lpv
        } p?4s9Un*SY
        .white_content { /mmEHD_(NX*D
            display: none;
~;v.Sq:?)L;s             position: absolute; j(t,GBW f
            top: 25%;
t:kv%| KB4M             left: 25%;
&_xW D%I             width: 50%; OulT`&DAh,q*F
            height: 50%; aX/O2w%MV
            padding: 16px;
v,a/^6W%q+||             border: 16px solid orange;
;KE P/nd4Q             background-color: white; o pO0_;Dlj S'jl
            z-index:1002;
~ n5i!~(H(f v9i             overflow: auto; 9bIiLd:W)j7~0|
        }
+~9l'oa!o!x     </style> U%[ JZ1k
    </head>
\!\jy'xk9a!P     <body> wq B;szL
        <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> &G(\7~*f k`Z/}
        <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> 9?4E-b&Y a C3@t#j;a
        <div id="fade" class="black_overlay"></div>
\D:rc6G!ep     </body>
O;P"g Y@'e:j </html>[/code]
页: [1]
查看完整版本: 纯CSS制作的网页中的lightbox效果