在页面中引入下面的文件。
<link rel="stylesheet" href="css/style.css"> <script src="js/spotlight.bundle.js"></script>
HTML结构
<a class="spotlight" href="gallery/t4.png"> <img src="gallery/t4.png" alt="Lorem ipsum dolor sit amet"> </a> <a class="spotlight" href="gallery/t5.png"> <img src="gallery/t5.png"> </a> <a class="spotlight" href="gallery/t6.png"> <img src="gallery/t6.png"> </a>
也可以不使用a标签。
<div class="spotlight-group"> <div class="spotlight image" data-src="gallery/t1.png" style="background-image:url(gallery/t1.png)"></div> <div class="spotlight image" data-src="gallery/t2.png" style="background-image:url(gallery/t2.png)"></div> <div class="spotlight image" data-src="gallery/t3.png" style="background-image:url(gallery/t3.png)"></div> </div>
要对图片进行分组,使用spotlight-group class即可。
<div class="spotlight-group"> <a class="spotlight" href="dog1.jpg"> <img src="dog1-thumb.jpg"> </a> <a class="spotlight" href="dog2.jpg"> <img src="dog2-thumb.jpg"> </a> <a class="spotlight" href="dog3.jpg"> <img src="dog3-thumb.jpg"> </a> </div> <div class="spotlight-group"> <a class="spotlight" href="cat1.jpg"> <img src="cat1-thumb.jpg"> </a> <a class="spotlight" href="cat2.jpg"> <img src="cat2-thumb.jpg"> </a> <a class="spotlight" href="cat3.jpg"> <img src="cat3-thumb.jpg"> </a> </div>