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