简体   繁体   English

jQuery datepicker导致页面溢出

[英]jQuery datepicker causes page overflow

I am using the datepicker control from jQuery-ui 1.8. 我正在使用jQuery-ui 1.8中的datepicker控件。 from-date is a text input. from-date是一个文本输入。 I am attaching a very simple datepicker: 我附加了一个非常简单的日期选择器:

$('#from-date').datepicker();

This causes the page to overflow (vertical scrollbar), which I am trying to avoid. 这会导致页面溢出(垂直滚动条),我试图避免。 As soon as I click the from-date, the datepicker control appears, and the scrollbar dissapears. 单击from-date后,将出现datepicker控件,滚动条消失。 After dismissing the datepicker, the scrollbar doesn't appear anymore. 在取消datepicker后,滚动条不再出现。

The text field is inside a div that has overflow:auto and a fixed height and width. 文本字段位于具有溢出的div内:auto和固定的高度和宽度。 I suspect it's a z-index issue. 我怀疑这是一个z指数问题。

What am I doing wrong ? 我究竟做错了什么 ? How would I debug this ? 我该怎么调试呢?

I had exactly the same problem. 我有完全相同的问题。 Wrapping Datepicker into a new div with a fixed position after the document is ready worked for me: 在文档准备就绪后,将Datepicker包装到具有固定位置的新div中:

$(document).ready(function() {
    // ...
    $("#ui-datepicker-div").wrap('<div style="position:absolute;top:0px;"></div>');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM