zoukankan      html  css  js  c++  java
  • Layui 数据表格显示图片,鼠标滑过图片放大

    Layui 数据表格显示图片,鼠标滑过图片放大

    <sricpt>
    table.render({
        elem: '#images',
        cellMinWidth: 80,
        url: '/........', //数据接口
        limit: 10,
        page: true, //开启分页
        cols: [
            [ //表头
                {
                    field: 'id',
                    title: 'ID',
                    sort: true,
                    fixed: 'left'
                },
                {
                    field: 'images',
                    title: '图片',
                    templet: '#showimg'  //自定义显示图片方法
                }
            ]
        ], 
        done:function(res,curr,count){
                hoverOpenImg();//显示大图
                $('table tr').on('click',function(){
                    $('table tr').css('background','');
                    $(this).css('background','<%=PropKit.use("config.properties").get("table_color")%>');
                });
            }
    });
     
    function hoverOpenImg(){
        var img_show = null; // tips提示
        $('td img').hover(function(){
            var kd=$(this).width();
            kd1=kd*3;          //图片放大倍数
            kd2=kd*3+30;       //图片放大倍数
            var img = "<img class='img_msg' src='"+$(this).attr('src')+"' style='"+kd1+"px;' />";
            img_show = layer.tips(img, this,{
                tips:[2, 'rgba(41,41,41,.5)']
                ,area: [kd2+'px']
            });
        },function(){
            layer.close(img_show);
        });
        $('td img').attr('style','max-70px;display:block!important');
    }
    </sricpt>
    <script type="text/html" id="showimg">
        <img src="{{ d.images}}"/>
    </script>

    原文:https://blog.csdn.net/yuzsmc/article/details/81977768

  • 相关阅读:
    【[USACO08FEB]酒店Hotel】
    【[USACO15JAN]草鉴定Grass Cownoisseur】
    【[USACO09DEC]牛收费路径Cow Toll Paths】
    【[HAOI2009]逆序对数列】
    【Hankson 的趣味题】
    【开车旅行】
    【[ZJOI2006]物流运输】
    【[HNOI2005]狡猾的商人】
    【愤怒的小鸟】
    【[HNOI2015]菜肴制作】
  • 原文地址:https://www.cnblogs.com/T8888/p/14134587.html
Copyright © 2011-2022 走看看