js图片画廊插件spotlight.js
时间:2022-10-26 20:51
浏览:0
评论:0
使用方法
在页面中引入下面的文件。
1 2 | < link rel = "stylesheet" href = "css/style.css" > < script src = "js/spotlight.bundle.js" ></ script > |
HTML结构
1 2 3 4 5 6 7 8 9 | < 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标签。
1 2 3 4 5 | < 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即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | < 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 > |