How to get ClockPicker for Bootstrap (Plugin) to appear in a Bootstrap Modal pop up form?

吃可爱长大的小学妹 提交于 2019-12-10 08:23:22

问题


Here is the link to ClockPicker for Bootstrap: http://www.jqueryrain.com/?B83aD_dg

It works perfectly; however, when I try to use it to fill in a text-input in a Bootstrap modal pop up, the clock appears behind the modal pop up. How can I get the clock picker to appear in (or in front of) the modal pop up instead?

Here is an image of what happens:

I've tried changing the z-index of the div to be in front; I've also tried changing the z-index of every element in clockpicker.css to be in front (for example: z-index: 1120). However, all this does is make the clock disappear.

<div class="modal fade appointment-modal"
     id="appointment-modal"
     tabindex="-1"
     role="dialog"
     aria-labelledby="myModalLabel"
     aria-hidden="true">

<div class="modal-dialog tutors-modal">
    <div class="modal-content tutors-modal">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">Appointment Scheduler</h4>
        </div>
        <div class="modal-body" style="height: 575px; left: 2.5%;">
            <div class="container">
                <div class="row">
                    <div class="col-md-12">     
                        <div class="alert alert-danger"><span class="glyphicon glyphicon-alert"></span>
                            <form role="form" action="/portal/make-appointment/" method="post" id="appointment_form" class="form-horizontal">
                                <div class="col-lg-6">

                                    <div class="input-group clockpicker" id = "clockpicker" style="padding: 6px; padding-bottom: 20px;">
                                        <input type="text" class="form-control" id = "time" name="time" value="08:00">
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-time"></span>
                                        </span>
                                    </div>
                                    <script type="text/javascript">
                                        var input = $('#time');
                                        input.clockpicker({
                                            autoclose: true
                                        });
                                    </script>
                                    <input type="submit" name="submit" id="submit" value="Schedule Appointment" class="btn btn-info pull-right">
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal-footer">
        </div>
    </div>
</div>


回答1:


I made a JSFiddle with your code.

As I suspected the problem is that the z-index of the modal is higher than the z-index of the clock-modal.

All you have to do in order to fix this is add this in your CSS:

.clockpicker-popover {
    z-index: 999999;
}



回答2:


just add this style to your clockpicker

.clockpicker-popover 
{
   z-index: 999999 !important;
}



回答3:


Solo ordena las hojas de estilo para sobreponer los elementos: Primero JQuery Seguido Clockpicker Y al final Bootstrap

Ejemplo:

<!-- jQuery -->
<script src="../librerias/jquery/jquery-3.4.1.min.js"></script>

<!-- Clockpicker -->
<link rel="stylesheet" type="text/css" href="../librerias/clockpicker/css/jquery-clockpicker.min.css">
<script type="text/javascript" src="../librerias/clockpicker/js/jquery-clockpicker.min.js"></script>

<!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="../librerias/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="../librerias/bootstrap/css/bootstrap.min.css">
<script src="../librerias/bootstrap/js/bootstrap.min.js"></script>


来源:https://stackoverflow.com/questions/23960866/how-to-get-clockpicker-for-bootstrap-plugin-to-appear-in-a-bootstrap-modal-pop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!