JS

Jquery实现图片放大两种方式

在开发过程中,有时候,我们遇到的需求:需要图片放大缩小。下面凯哥就介绍两种实习方式一:弹窗层显示放大后的图片二:鼠标悬浮放大后的图片以下正文说明:jquery.min.js和图片请自行修改一:弹窗层显示放大后的图片,点击图片后缩小效果图:代码:<head><style type="text/css">.fillbg { ba

在开发过程中,有时候,我们遇到的需求:需要图片放大缩小。

下面凯哥就介绍两种实习方式

一:弹窗层显示放大后的图片

二:鼠标悬浮放大后的图片

以下正文

说明:jquery.min.js和图片请自行修改

一:弹窗层显示放大后的图片,点击图片后缩小

效果图:

9e3299b4325486d03c2d28048f289595.png

代码:

<head>

<style type="text/css">
.fillbg { background-color: rgba(0, 0, 0, 0.6); bottom: 0; height: 100%; left: 0; opacity: 0; position: fixed; right: 0; top: 0; width: 100%; z-index: 1100; display:none; }
.fillbg-active { opacity: 1; display:block; }
</style>
</head>

<script src="http://localhost:8090/js/jquery.min.js"></script>

<img class="comment_pics" width="50px" height="50px" src="http://localhost:8090/profile/pic/imgs/pic7986627563.JPG"/>

<div class="bg">
    <img class="bgImg" style="max-width: 100%; max-height: 100%; position: fixed;" src="">
</div>

<script>
    var newImg;
    var clientH=$(window).height();
    var clientW=$(window).width();
    var w = '250';
    var h = '250';
    $(document).ready(function(){
        $(".comment_pics").bind("click", function(){
            newImg = $(thi

原创不易,完成人机校验,阅读全文

相关推荐