html
EasyZoom不依赖于特定的标记结构但重要的是EasyZoom目标元素 (<div class="easyzoom">)只包含一个链接到大图和较小的图像。其他元素目标必须不影响其布局,如绝对定位的元素。
1 2 3 4 5 | < div class = "easyzoom" > < a href = "images/zoom.jpg" > < img src = "images/standard.jpg" alt = "" /> </ a > </ div > |
CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* Shrink wrap strategy 1 */ .easyzoom { float : left ; } .easyzoom img { display : block ; } /* Shrink wrap strategy 2 */ .easyzoom { display : inline- block ; } .easyzoom img { vertical-align : bottom ; } |
JavaScript
1 2 3 4 | // Instantiate EasyZoom plugin var $easyzoom = $( '.easyzoom' ).easyZoom(); // Get the instance API var api = $easyzoom.data( 'easyZoom' ); |