layui 点击图片放大

        $(document).on('click', '.img_sp', function(data){
            var imgSrc=$(this).attr('src');
            layer.open({
                type:1
                ,title:false
                ,closeBtn:0
                ,skin:'layui-layer-nobg'
                ,shadeClose:true
                ,content:'<img style="width:100%;height:100%;" class="layui-upload-img" src="'+ imgSrc +'"/>'
                ,scrollbar:false
            })
        });
var area = [];
        if (window.screen.width > 1680 && window.screen.width <= 1920) {
            area = ['58%', '96%']
        } else if (window.screen.width > 1600 && window.screen.width <= 1680) {
            area = ['78%', '86%']
        } else if (window.screen.width > 1366 && window.screen.width <= 1600) {
            area = ['78%', '86%']
        } else if (window.screen.width <= 1366) {
            area = ['78%', '86%']
        }

        $(document).on('click','.imgs',function(){
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true, //点击阴影关闭
                area: area , //宽高
                // area: [$(this).width + 'px', $(this).height + 'px'], //宽高
                content: "<img src=" + $(this).attr('src') + " />"
            });
        });

 

posted @ 2021-11-29 18:42  -韩  阅读(588)  评论(0编辑  收藏  举报