怎么用CSS3实现lightbox图片弹层效果
这篇文章主要介绍“怎么用CSS3实现lightbox图片弹层效果”,在日常操作中,相信很多人在怎么用CSS3实现lightbox图片弹层效果问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么用CSS3实现lightbox图片弹层效果”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!
使用方法
HTML结构
在页面中引入perfundo-icons.css文件。
<link href="dist/perfundo.css" rel="stylesheet">
HTML结构
单张图片的HTML结构如下:
<p class="perfundo"> <style> #perfundo-single:target:before{background-image:url(large.jpg);} </style> <a class="perfundo__link" href="#perfundo-single"> <img src="small.jpg"> </a> <p id="perfundo-single" class="perfundo__overlay"> <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a> </p></p>
多张图片的HTML结构如下:
<p class="perfundo"> <style>#perfundo-img1:target:before{background-image:url(1.jpg);}</style> <a class="perfundo__link" href="#perfundo-img1"> <img src="1.jpg"> </a> <p id="perfundo-img1" class="perfundo__overlay"> <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a> <a class="perfundo__next perfundo__control" href="#perfundo-img2">Next</a> </p></p> <p class="perfundo"> <style>#perfundo-img2:target:before{background-image:url(2.jpg);}</style> <a class="perfundo__link" href="#perfundo-img2"> <img src="2.jpg"> </a> <p id="perfundo-img2" class="perfundo__overlay"> <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a> <a class="perfundo__next perfundo__control" href="#perfundo-img3">Next</a> <a class="perfundo__prev perfundo__control" href="#perfundo-img1">Prev</a> </p></p> <p class="perfundo"> <style>#perfundo-img3:target:before{background-image:url(3.jpg);}</style> <a class="perfundo__link" href="#perfundo-img3"> <img src="3.jpg"> </a> <p id="perfundo-img3" class="perfundo__overlay"> <a href="#perfundo-untarget" class="perfundo__close perfundo__control">Close</a> <a class="perfundo__prev perfundo__control" href="#perfundo-img2">Prev</a> </p></p>
结合JS的用法
你也可以结合js一起使用。
<!-- Put this inside the <head> section of your HTML. --><link rel="stylesheet" href="perfundo.min.css"><!-- Put this before the closing </body> tag (optionally!). --><script src="perfundo.min.js"></script><script> perfundo('.perfundo');</script>
您还可以到Github上了解更多有关该效果的使用情况:https://github.com/maoberlehner/perfundo
到此,关于“怎么用CSS3实现lightbox图片弹层效果”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注网站,小编会继续努力为大家带来更多实用的文章!