CSS动态定位

$(document).ready(function(){
        $('body').on('click', '#start_timer', function() {
            var laydate = $(".layui-laydate");
            laydate.hide();
            if(laydate && laydate.length>0){
                laydate.show();
                var top = $(".layui-layer")[0].offsetTop;
                var left = $(".layui-layer")[0].offsetLeft;
                var top1 = top + 84;
                var left1 = left + 217 ; 
                $(".layui-laydate").css("top",top1);
                $(".layui-laydate").css("left",left1);
            }
        })
        
        $('body').on('click', '#end_timer', function() {
            var laydate = $(".layui-laydate");
            laydate.hide();
            if(laydate && laydate.length>0){
                laydate.show();
                var top = $(".layui-layer")[0].offsetTop;
                var left = $(".layui-layer")[0].offsetLeft;
                var top1 = top + 133;
                var left1 = left + 217 ; 
                $(".layui-laydate").css("top",top1);
                $(".layui-laydate").css("left",left1);
            }
        })
    });
    
    

 

转载于:https://www.cnblogs.com/whoknows1/p/9685986.html

你可能感兴趣的:(CSS动态定位)