layer.tips自定义位置



function Definitionlayertips(msg, obj, classObj) {//msg提示信息,obj当前元素,classObj吸附滚动的容器
    obj[0].scrollIntoView({behavior: "instant", block: "center", inline: "nearest"});
    layer.tips(msg, obj, {
        tipsMore: true,
        tips: 2,
        success: function (layero, index) {
            //需要吸附滚动的有滚动条的那个容器
            var domParent = classObj;
            //滚动条当前顶部距离
            var scrollTop = domParent[0].scrollTop;
            var widthTips = domParent[0].scrollWidth - (obj.offset().left + obj[0].scrollWidth);
            widthTips = widthTips>110?110:widthTips;
            //当前 tips 的top + 滚动条的顶部距离 + 容器的顶部距离(如:48)为新的top
            layero.css("top", layero.offset().top + 1 + scrollTop);
            layero.css("left", obj.offset().left + obj[0].scrollWidth + 20);
            layero.css("width", widthTips + 'px');
            $(layero).find("i").css("right",parseInt($(layero).find("i").css("right").split("px")[0]) + widthTips);
            domParent.append(layero);
        }
    });
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM