日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
前端工作中碰到的一些東西

久不出技術(shù)類文章,我都忘了自己是一程序員啦......今天寫一點(diǎn)工作中遇到的東西,大家共同學(xué)習(xí),反正也比較淺顯了。

在安圖等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作按需求定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),營(yíng)銷型網(wǎng)站建設(shè),成都外貿(mào)網(wǎng)站建設(shè)公司,安圖網(wǎng)站建設(shè)費(fèi)用合理。

彈出窗口

我們?cè)诠ぷ髦校?jīng)常會(huì)碰到彈出窗口類應(yīng)用,有時(shí)候還需要一點(diǎn)遮蓋層:

這類圓角彈出框其實(shí)用得還是很廣泛的,用CSS3可以很容易的出現(xiàn),但是考慮到瀏覽器兼容問(wèn)題,這類還是需要用圖片實(shí)現(xiàn)了

主要代碼如下:

 
 
 
 
  1. //彈出層劇中   
  2.        function popup(popupName) {   
  3.            var _scrollHeight = $(document).scrollTop(); //獲取當(dāng)前窗口距離頁(yè)面頂部高度   
  4.            _windowHeight = $(window).height(); //獲取當(dāng)前窗口高度   
  5.            _windowWidth = $(window).width(); //獲取當(dāng)前窗口寬度   
  6.            _popupHeight = popupName.height(); //獲取彈出層高度   
  7.            _popupWeight = popupName.width(); //獲取彈出層寬度   
  8.            //            _posiTop = (_windowHeight - _popupHeight) / 2 + _scrollHeight - 50;   
  9.            _posiTop = _scrollHeight + 120;   
  10.            _posiLeft = (_windowWidth - _popupWeight) / 2;   
  11.            popupName.css({ "left": _posiLeft + "px", "top": _posiTop + "px", "display": "block" }); //設(shè)置position   
  12.        }   
  13.    
  14.        function dragFunc(dragDiv, dragBody) {   
  15.            if (dragDiv[0] && dragBody[0]) {   
  16.                var dragAble = false;   
  17.                var x1 = 0;   
  18.                var y1 = 0;   
  19.                var l = 0;   
  20.                var t = 0;   
  21.                var divOffset = dragBody.offset();   
  22.                dragDiv.mousedown(function (e) {   
  23.                    var ss = this;   
  24.                    //                    var rootId =    
  25.    
  26.                    dragDiv.css("cursor", "move");   
  27.                    dragAble = true;   
  28.                    // 當(dāng)前鼠標(biāo)距離div邊框的距離   
  29.                    // 當(dāng)前鼠標(biāo)坐標(biāo),減去div相對(duì)左邊的像素   
  30.                    l = parseInt(dragBody.css("left"));   
  31.                    t = parseInt(dragBody.css("top"));   
  32.                    x1 = e.clientX - l;   
  33.                    y1 = e.clientY - t;   
  34.                    x1x1 = x1 > 0 ? x1 : 0;   
  35.                    y1y1 = y1 > 0 ? y1 : 0;   
  36.                    this.setCapture && this.setCapture();   
  37.                });   
  38.                dragDiv.mousemove(function (e) {   
  39.                    if (!dragAble)   
  40.                        return;   
  41.                    // 當(dāng)前div左邊的坐標(biāo)   
  42.                    // 當(dāng)前鼠標(biāo)坐標(biāo),減去鼠標(biāo)拖動(dòng)量   
  43.                    var x2 = 0;   
  44.                    var y2 = 0;   
  45.                    //需要考慮滾動(dòng)條問(wèn)題?。?!   
  46.                    var top = $(document).scrollTop() ? $(document).scrollTop() - 15 : 0;   
  47.                    var left = $(document).scrollLeft() ? $(document).scrollLeft() - 15 : 0;   
  48.                    x2 = e.clientX - x1 + left;   
  49.                    y2 = e.clientY - y1 + top;   
  50.                    x2x2 = x2 > 0 ? x2 : 0;   
  51.                    y2y2 = y2 > 0 ? y2 : 0;   
  52.                    //要移動(dòng)一定數(shù)量才移動(dòng)   
  53.                    if (Math.abs(l - x2) > 10 || Math.abs(t - y2) > 10) {   
  54.                        dragBody.css("left", x2 + "px");   
  55.                        dragBody.css("top", y2 + "px");   
  56.                    }   
  57.                });   
  58.                dragDiv.mouseup(function (event) {   
  59.                    if (!dragAble)   
  60.                        return;   
  61.                    dragAble = false;   
  62.                    // dragDiv.css("position", "relative");   
  63.                    this.releaseCapture && this.releaseCapture();   
  64.                });   
  65.            }   
  66.        }   
  67.    
  68.        var MyDialog = function (cfg) {   
  69.            this.config = {   
  70.                id: (new Date()).getTime().toString(),   
  71.                el: null,   
  72.                bodyId: null,   
  73.                cover: true,   
  74.                boxHtm: '  ' +   
  75.        '   ' +   
  76.        '      ' +   
  77.        '        ' +   
  78.        '         ' +   
  79.        '         ' +   
  80.        '         ' +   
  81.        '         ' +   
  82.        '         ' +   
  83.        '     ' +   
  84.        '    
  85.  ' +   
  86.        '         ' +   
  87.        '          ' +   
  88.        '         ' +   
  89.        '         ' +   
  90.        '             ' +   
  91.        '                

     ' +   

  92.        '                    請(qǐng)輸入標(biāo)題  ' +   
  93.        '                 ' +   
  94.        '             ' +   
  95.        '             ' +   
  96.        '             請(qǐng)輸入內(nèi)容   ' +   
  97.        '             ' +   
  98.        '         ' +   
  99.        '         ' +   
  100.        '         ' +   
  101.        '    
  102.  ' +   
  103.        '     ' +   
  104.        '         ' +   
  105.        '         ' +   
  106.        '         ' +   
  107.        '          ' +   
  108.        '         ' +   
  109.        '         ' +   
  110.        '         ' +   
  111.        '     ' +   
  112.        '
  113.  ' +   
  114.    '
'  
  •            };   
  •            var scope = this;   
  •            if (cfg) {   
  •                $.each(cfg, function (key, value) {   
  •                    scope.config[key] = value;   
  •                });   
  •            }   
  •            this.box = null;   
  •            this.cover = null;   
  •            this.tmpBody = null;   
  •        }   
  •    
  •    
  •        MyDialog.prototype.show = function () {   
  •            var scope = this;   
  •            var cover = null;   
  •            var box = null;   
  •            if (this.config.cover) {   
  •                if (this.config.id && $('#' + this.config.id + '_cover')[0]) {   
  •                    cover = $('#' + this.config.id + '_cover');   
  •                    cover.show();   
  •                } else {   
  •                    cover = $('
  • ');   
  •                    $('body').append(cover);   
  •                }   
  •                scope.cover = cover;   
  •            }   
  •            if (!$('#' + this.config.id)[0]) {   
  •                box = $(this.config.boxHtm);   
  •                $('body').append(box);   
  •                box.attr('id', this.config.id);   
  •                if (this.config.title) {   
  •                    box.find('.title_text').html(this.config.title);   
  •                }   
  •                if (this.config.bodyId) {   
  •                    var body = $('#' + this.config.bodyId);   
  •                    var tmp = $('
    ').append(body);   
  •                    var initBody = tmp.html();   
  •                    scope.tmpBody = $(initBody);   
  •                    tmp = null;   
  •                    if (body[0]) {   
  •                        var con = box.find('.main .content');   
  •                        body.show();   
  •                        con.html('');   
  •                        con.append(body);   
  •                    }   
  •                }   
  •                if (this.config.el && this.config.el[0]) {   
  •                    var con = box.find('.main .content');   
  •                    con.html(this.config.el);   
  •                }   
  •                //居中   
  •                popup(box);   
  •                //關(guān)閉dialog   
  •                box.find('.title .cls').click(function (e) {   
  •                    scope.close();   
  •                    e.preventDefault();   
  •                    return false;   
  •                });   
  •    
  •                dragFunc($('#' + this.config.id + ' .main .title'), $('#' + this.config.id));   
  •                box.show();   
  •                this.box = box;   
  •            }   
  •        }   
  •        MyDialog.prototype.close = function () {   
  •            //這里有問(wèn)題   
  •            var box = this.box;   
  •            var tmpBody = this.tmpBody;   
  •            var cover = this.cover;   
  •            if (tmpBody && tmpBody[0]) {   
  •                $('body').append(tmpBody);   
  •            }   
  •            if (box && box[0]) {   
  •                box.remove();   
  •            }   
  •            if (cover && cover[0]) {   
  •                cover.hide();   
  •            }   
  •        }; 
  • 調(diào)用方法:

     
     
     
     
    1. var dia = new MyDialog({   
    2.                 title : title,   
    3.                 bodyId : id,   
    4.                 id : id + '_box'  
    5.             });   
    6.             dia.show(); 

    具體可能還需要一定函數(shù)回調(diào),各位可以自己封裝一番。

    拖放

    工作中也經(jīng)常會(huì)出現(xiàn)拖放效果的一些需求:

    代碼如下:

     
     
     
     
    1.    
    2.    
    3.    
    4.        
    5.        
    6.