e-smart-zoom-jquery.js插件,本文通过实例代码给大家简单介绍了jquery图片缩放插件smartzoom使用以及遇到问题的解决方法,非常不错,具有参考借鉴价值,需要的朋友参考下吧,希望能帮助到大家。
插件描述:通过将鼠标悬停在图片上,滚动鼠标滚轮即可实现图片的放大或者缩小效果。
smartZoom使用
举个例子,上代码:
nbsp;html> <meta> <title>joannau</title> <style> * { padding: 0; margin: 0; } .imgCon { width: 800px; height: 500px; margin: 40px auto; border: 2px solid #000; } .imgp { width: 100%; height: 100%; } .imgCon img{ width: 100%; } </style><p> </p><p> <img alt="jQuery图片缩放插件smartZoom使用方法分享" > </p> <script></script><script></script><script> $(function () { $(".imgCon img").smartZoom() }) </script>
直接对img对象使用smartZoom方法即可。
查看效果:
缩放
完美,这就成功使用了。
但很多人会遇见使用smartZoom图片位置偏移的问题,效果如下:
边框不见,再看代码会发现:
原来是top和left作祟。此时解决问题的重点就是在img图像外,嵌套一个p容器。如下:
<p> <img alt="jQuery图片缩放插件smartZoom使用方法分享" > </p>
此时,便能解决位置偏移问题。
其他API:
// 方法中可以通过设置top,left等参数来指定图片初始参数; $(".imgCon img").smartZoom({ 'left': '50px' }) // 通过传入‘destroy‘来取消缩放; $(".imgCon img").smartZoom('destroy')
相关推荐:
以上就是jQuery图片缩放插件smartZoom使用方法分享的详细内容,更多请关注php中文网其它相关文章!
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号