1. 程式人生 > 其它 >layui 點選圖片放大

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') + " />" }); });