在Safari浏览器中,jQuery UI的日期选择器(Datepicker)控件可能会出现黑色背景或异常显示的问题。
这个问题通常由以下几个原因导致:
/* 针对Safari的日期选择器修复 */
@media screen and (-webkit-min-device-pixel-ratio:0) {
.ui-datepicker {
background: white !important;
border: 1px solid #ccc !important;
}
.ui-datepicker-header {
background: #f6f6f6 !important;
}
}
.ui-datepicker {
z-index: 1000 !important;
}
<!-- 确保在jQuery之后引入jQuery UI CSS -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
使用最新版本的jQuery UI,许多浏览器兼容性问题在新版本中已修复。
确保日期选择器正确初始化:
$(function() {
$("#datepicker").datepicker({
showButtonPanel: true,
dateFormat: "yy-mm-dd"
});
});
这个问题主要出现在:
如果问题持续存在,可以考虑:
<input type="date">
通过以上方法,应该能够解决Safari中jQuery UI日期选择器黑色背景的问题。
没有搜到相关的文章