国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > JS > 正文

bootstrap datetimepicker控件位置異常的解決方法

2024-05-06 16:41:05
字體:
來源:轉載
供稿:網友

今天在寫畢設的時候,用到了bootstrap-datetimepicker作為日期控件。

在git上clone下最新的代碼,運行demo,發現控件區域整體下移1000px左右。

作為一個準備拿來就用的后臺程序猿,此刻我的內心是崩潰的…

百度了很久,沒有找到對應的解決方案,于是自己動手去源碼修改。

最終解決方案:

打開源碼,的bootstrap-datetimepicker.js文件

line 527行,打開這一段注釋即可

 /*if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {    top = offset.top - this.picker.outerHeight();   } else {    top = offset.top + this.height;   }*/

如果看著還是不是很舒服的話,建議注釋掉line 533 - line 544

top = top - containerOffset.top + 169;left = left - containerOffset.left + 210;

為什么要這樣解決呢?

  place: function () {   if (this.isInline) return;   if (!this.zIndex) {    var index_highest = 0;    $('div').each(function () {     var index_current = parseInt($(this).css('zIndex'), 10);     if (index_current > index_highest) {      index_highest = index_current;     }    });    this.zIndex = index_highest + 10;   }   var offset, top, left, containerOffset;   if (this.container instanceof $) {    containerOffset = this.container.offset();   } else {    containerOffset = $(this.container).offset();   }   if (this.component) {    offset = this.component.offset();    left = offset.left;    if (this.pickerPosition == 'bottom-left' || this.pickerPosition == 'top-left') {     left += this.component.outerWidth() - this.picker.outerWidth();    }   } else {    offset = this.element.offset();    left = offset.left;   }   var bodyWidth = document.body.clientWidth || window.innerWidth;   if (left + 220 > bodyWidth) {    left = bodyWidth - 220;   }   /*if (this.pickerPosition == 'top-left' || this.pickerPosition == 'top-right') {    top = offset.top - this.picker.outerHeight();   } else {    top = offset.top + this.height;   }*/   top = top - containerOffset.top + 169;   left = left - containerOffset.left + 210;   this.picker.css({    top:  top,    left:  left,    zIndex: this.zIndex   });  },

上面就是相關的源碼,可以看到,注釋了line 527行之后,在后面引用了一個未初始化過的top變量

嗯… 這是一個沒經過測試就提交的小BUG…

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 伊宁市| 南木林县| 治多县| 剑河县| 西城区| 银川市| 越西县| 定边县| 微山县| 客服| 商河县| 三门县| 新龙县| 宣威市| 金堂县| 平舆县| 双峰县| 藁城市| 汉中市| 如皋市| 搜索| 安陆市| 阜南县| 江口县| 哈尔滨市| 恩平市| 云林县| 荣成市| 安多县| 玉龙| 北宁市| 桂平市| 洛南县| 黄平县| 开封市| 西乌珠穆沁旗| 巩义市| 长汀县| 九龙坡区| 大足县| 岳普湖县|