【问题标题】:Bootstrap Datepicker is displaying behind popoverBootstrap Datepicker 显示在弹出框后面
【发布时间】:2013-05-29 15:16:01
【问题描述】:

我正在尝试在弹出窗口中显示一个日期选择器(使用 bootstrap 和 bootstrap-datepicker 扩展)并且遇到了一些问题, 首先,我在显示日期选择器时遇到问题并找到了这个主题:Datepicker in Popover Won't display ,但现在它显示在我的弹出框后面,所以它不完全可见

这是 HTML 代码:

<button type="submit" class="btn btn-primary pop_doleance" rel="popover" data-original-title="Ajouter doléance">Ajouter doléance</button>

<div style="display: none" class="pop_doleance_content">
<form class="well form-inline form_doleance">
    <label for="date">Date : </label>
    <input id="date" type="text" class="input-medium">
</form>

还有 Javascript 代码:

var tmp = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function (){
    tmp.call(this);
    if (this.options.callback) {
    this.options.callback();
    }
}

$(function (){
    $(".pop_doleance").popover({
        placement:'bottom', 
        html : true, 
        content: function(){return $('.pop_doleance_content').html();},
        callback: function(){$('#date').datepicker();}
    });  
});

有什么想法吗?

【问题讨论】:

    标签: javascript jquery html twitter-bootstrap datepicker


    【解决方案1】:

    将弹出窗口的 z-index 设置为较低的值。

    .popup { z-index : 900; }
    

    并将 datepicker 的容器 z-index 设置为更高的值,例如 jquery ui datepicker set

    .ui-datepicker-div { z-index: 999; }
    

    【讨论】:

    • 所以我尝试了您的解决方案。 HTML : &lt;div id="divdate"&gt; &lt;label for="date"&gt;Date : &lt;/label&gt; &lt;input id="date" type="text" class="input-medium"&gt;&lt;br/&gt; &lt;/div&gt; CSS : .pop_doleance { z-index: 900; } .pop_doleance_content { z-index : 933; } .form_doleance { z-index: 966; } #divdate { z-index: 999; } 如果我做错了告诉我
    • 对不起,我第一次没明白你的意思,我只是为扩展的.datepicker类创建了一个z-index。非常感谢
    【解决方案2】:

    在我添加的css中:

    .datepicker { 
        z-index: 999 !important;
    }
    

    注意“!重要”。没有这个就不行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-01
      • 1970-01-01
      • 2018-08-24
      • 1970-01-01
      • 2018-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多