Jquery日期选择器z索引问题

发布于 2024-11-29 10:31:36 字数 419 浏览 4 评论 0原文

我有一个幻灯片 div,并且在该 div 上方有一个日期选择器字段。

当我单击日期选择器字段时,日期选择器面板显示在幻灯片 div 后面。

我将脚本设置为:

http://ajax.googleapis。 com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js

所以我无法更改CSS中datepicker的z索引。脚本生成的日期选择器的 z 索引是 1,我的幻灯片 div(也通过 googleajaxapi 调用)z 索引是 5。所以我想我必须将日期选择器的 z 索引增加到大于 5。所以有吗有什么办法可以增加吗?

有人可以帮助我吗?

I have a slideshow div, and I have a datepicker field above that div.

When I click in the datepicker field, the datepicker panel show behind slideshow div.

And I have put the script as:

http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js

So I cannot change the z-index of datepicker in CSS. The z-index of datepicker which the script is generating is 1 and my slideshow div(also calling thru googleajaxapi) z-index is 5. So I guess I have to increase the z-index of date picker greater than 5. So is there any way to increase it ?

Someone can help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

数理化全能战士 2024-12-06 10:31:36

将以下样式放置在“输入”文本元素处: position:relative; z 索引:100000;

datepicker div 从输入中获取 z-index,但这仅在位置是相对的时有效。

使用这种方式,您不必从 jQuery UI 修改任何 javascript。

Put the following style at the 'input' text element: position: relative; z-index: 100000;.

The datepicker div takes the z-index from the input, but this works only if the position is relative.

Using this way you don't have to modify any javascript from jQuery UI.

狂之美人 2024-12-06 10:31:36

只需在您的 CSS 中使用 '.ui-datepicker{ z-index: 9999 !important;}' 这里 9999 可以替换为您希望日期选择器可用的任何图层值。任何代码都不应被注释,也不应在输入元素上添加“position:relative;”CSS。因为增加输​​入元素的 z-index 将对所有输入类型按钮产生影响,这在某些情况下可能不需要。

simply in your css use '.ui-datepicker{ z-index: 9999 !important;}' Here 9999 can be replaced to whatever layer value you want your datepicker available. Neither any code is to be commented nor adding 'position:relative;' css on input elements. Because increasing the z-index of input elements will have effect on all input type buttons, which may not be needed for some cases.

憧憬巴黎街头的黎明 2024-12-06 10:31:36

为我工作

.hasDatepicker {
    position: relative;
    z-index: 9999;
}

worked for me

.hasDatepicker {
    position: relative;
    z-index: 9999;
}
2024-12-06 10:31:36

基于marksyzm答案,这对我有用:

$('input').datepicker({
    beforeShow:function(input) {
        $(input).css({
            "position": "relative",
            "z-index": 999999
        });
    }
});

Based in marksyzm answer, this worked for me:

$('input').datepicker({
    beforeShow:function(input) {
        $(input).css({
            "position": "relative",
            "z-index": 999999
        });
    }
});
半暖夏伤 2024-12-06 10:31:36

我有一个使用日期选择器的对话框。它一直是隐藏的。当我调整 z-index 时,下部表单上的字段始终显示在对话框中。

我使用了我所看到的解决方案的组合来解决该问题。

$('.ui-datepicker', $form).datepicker({
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-M-dd",
                beforeShow: function (input) {
                    $(input).css({
                        "position": "relative",
                        "z-index": 999999
                    });
                },
                onClose: function () { $('.ui-datepicker').css({ 'z-index': 0  } ); }                    
            });

before show 确保日期选择器在选择时始终位于顶部,但 onClose 确保重置字段的 z-index,以便它不会与稍后使用不同日期选择器打开的任何对话框重叠。

I have a dialog box that uses the datepicker on it. It was always hidden. When I adjusted the z-index, the field on the lower form always showed up on the dialog.

I used a combination of solutions that I saw to resolve the issue.

$('.ui-datepicker', $form).datepicker({
                showButtonPanel: true,
                changeMonth: true,
                changeYear: true,
                dateFormat: "yy-M-dd",
                beforeShow: function (input) {
                    $(input).css({
                        "position": "relative",
                        "z-index": 999999
                    });
                },
                onClose: function () { $('.ui-datepicker').css({ 'z-index': 0  } ); }                    
            });

The before show ensures that datepicker always is on top when selected, but the onClose ensures that the z-index of the field gets reset so that it doesn't overlap on any dialogs opened later with a different datepicker.

清泪尽 2024-12-06 10:31:36

添加贾斯汀的答案,如果您担心标记不整齐或者您不希望在 CSS 中硬编码该值,您可以在显示之前设置输入。像这样的事情:

$('input').datepicker({
    beforeShow:function(input){
        $(input).dialog("widget").css({
            "position": "relative",
            "z-index": 20
        });
    }
});

请注意,您不能省略 "position": "relative" 规则,因为插件要么在两个规则或样式表的内联样式中查找,但不能同时查找两者。

dialog("widget") 是弹出的实际日期选择器。

Adding to Justin's answer, if you're worried about untidy markup or you don't want this value hard coded in CSS you can set the input before it is shown. Something like this:

$('input').datepicker({
    beforeShow:function(input){
        $(input).dialog("widget").css({
            "position": "relative",
            "z-index": 20
        });
    }
});

Note that you cannot omit the "position": "relative" rule, as the plugin either looks in the inline style for both rules or the stylesheet, but not both.

The dialog("widget") is the actual datepicker that pops up.

驱逐舰岛风号 2024-12-06 10:31:36

我通过使用单击解决了这个问题:

var checkin = $('.dpd1').datepicker()
.on('click', function (ev) {
        $('.datepicker').css("z-index", "999999999");
}).data('datepicker');

I had this issue i solved by using on click:

var checkin = $('.dpd1').datepicker()
.on('click', function (ev) {
        $('.datepicker').css("z-index", "999999999");
}).data('datepicker');
顾挽 2024-12-06 10:31:36

我有一个页面,其中日期选择器位于 datatables.net tabletools 按钮的顶部。
数据表按钮比单个日期选择器日期按钮具有更高的 z-index。
感谢Ronye的回答,我能够通过使用position:relative;来解决这个问题。 z 索引:10000。
谢谢!

I have a page where the datepicker was on top of a datatables.net tabletools button.
The datatables buttons had a higher z-index than the individual datepicker date buttons.
Thanks to Ronye's answer I was able to resolve this problem by using position: relative; and z-index: 10000.
Thanks!

梦途 2024-12-06 10:31:36

当我错过主题时,这发生在我身上。确保主题存在,或者重新下载主题,然后将其重新上传到您的服务器。

This happened to me when I was missing the theme. Make sure the theme exists, or perhaps redownoad the theme, and reupload it to your server.

牵强ㄟ 2024-12-06 10:31:36

这解决了我的问题:

 $( document ).ready(function() {   
    $('#datepickerid').datepicker({
     zIndexOffset: 1040 #or any number you want
     });
});

That what solved my problem:

 $( document ).ready(function() {   
    $('#datepickerid').datepicker({
     zIndexOffset: 1040 #or any number you want
     });
});
左岸枫 2024-12-06 10:31:36

事实上,您可以有效地在 css 中添加 .ui-datepicker{ z-index: 9999 !important;} 但您可以修改 jquery-ui.cssjquery-ui.min.css 并添加到 ui-datepicker 类的末尾 z-index: 9999 !important;。这两件事都对我有用(你只需要一个;-))

In fact you can effectively add in your css .ui-datepicker{ z-index: 9999 !important;} but you can modify jquery-ui.css or jquery-ui.min.css and add at the end of the ui-datepicker class z-index: 9999 !important;. both things work for me (You only need one ;-))

清风疏影 2024-12-06 10:31:36

我不得不

.datepicker.dropdown-menu {
    position: relative;
    z-index: 9999 !important;
}

I had to

.datepicker.dropdown-menu {
    position: relative;
    z-index: 9999 !important;
}
莳間冲淡了誓言ζ 2024-12-06 10:31:36

我也遇到了这个问题,因为日期选择器使用输入的 z-index,所以我添加了以下 css

#dialogID input,.modal-dialog input, .modal-dialog .input-group .form-control{
  z-index:inherit;
}

只需采用适用于您的规则,通过父 id、类,或者在我的情况下是引导对话框,使用它们的输入 -组和形式控制。

I had this issue as well, since the datepicker uses the input's z-index, I added the following css

#dialogID input,.modal-dialog input, .modal-dialog .input-group .form-control{
  z-index:inherit;
}

Just take the rule that applies to yours, either by parent id, class, or in my case a bootstrap dialog, using their input-group and form-control.

但可醉心 2024-12-06 10:31:36

30脉冲尝试
最后我明白了。 工作

.modal {
    z-index: 1040; // Bootstrap 3 Model
}
.ui-datepicker {
    z-index: 1041 !important;
}

30 puls try
Last I get it. Working

.modal {
    z-index: 1040; // Bootstrap 3 Model
}
.ui-datepicker {
    z-index: 1041 !important;
}

过气美图社 2024-12-06 10:31:36

对我来说问题是日期选择器从最近的具有 z 索引的父级获取 z 索引,然后添加 +1。假设 z-index 最接近的值是 1000,那么日期选择器得到 1001。

但是!当你仍然有一个具有更高 z-index 的父元素时,你就会遇到问题!

<div style="z-index: 2000">
    <!-- The highest parent has 2000 -->
    <div style="z-index: 1000">
        <!-- the closest parent has 1000 -->
        <input class"datepicker" />
        <!-- your datepicker popup will get 1001 -->
        <!-- but that is too low to go over your outer parent's z-index of 2000 -->
    </div>
</div>

所以这实际上是你父母的z-indexs的问题。

The problem for me was that the datepicker takes the z-index from the closest parent which has a z-index and then adds +1. So let say the closest one with z-index is 1000 so the datepicker gets 1001.

But! When you still have a parent element with an even higher z-index then you will have a problem!

<div style="z-index: 2000">
    <!-- The highest parent has 2000 -->
    <div style="z-index: 1000">
        <!-- the closest parent has 1000 -->
        <input class"datepicker" />
        <!-- your datepicker popup will get 1001 -->
        <!-- but that is too low to go over your outer parent's z-index of 2000 -->
    </div>
</div>

So it is actually a problem with the z-indexes of your parents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文