jQuery-UI Datepicker CSS 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/460263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery-UI Datepicker CSS problem
提问by Andre Gallo
I've got this pretty simple HTML page with a jQuery datepicker:
我有一个带有 jQuery 日期选择器的非常简单的 HTML 页面:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQuery Datepicker</title>
<link rel="stylesheet" href="../App_Themes/Default/ui.datepicker.css" type="text/css"
media="screen" title="Smoothness" />
<script src="../Shared/Scripts/jquery-1.2.6.min.js" type="text/javascript"></script>
<script src="../Shared/Scripts/jquery-ui-1.5.3.min.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(PageLoad);
function PageLoad() {
$('#textBox').datepicker();
}
</script>
</head>
<body>
<input type="text" id="textBox" />
</body>
</html>
The datepicker itself seems to work perfectly but I can't apply my theme. Am I missing something really stupid here?
日期选择器本身似乎运行良好,但我无法应用我的主题。我在这里错过了一些非常愚蠢的东西吗?
Thanks !!!!
谢谢 !!!!
回答by bart
If you load jQueryUI through Google, make sure the jQueryUI CSS theme has the same version as the jQueryUI library.
如果您通过 Google 加载 jQueryUI,请确保 jQueryUI CSS 主题与 jQueryUI 库具有相同的版本。
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js' type='text/javascript'></script>
Check the above code, both use 1.8.5. But if you load 1.8 instead of 1.8.5 for the theme the datapicker won't show up.
检查上面的代码,都使用1.8.5。但是,如果您为主题加载 1.8 而不是 1.8.5,数据选择器将不会显示。
回答by Andre Gallo
My problem wasn't about the CSS validity or relative paths .... I was just referencing the wrong version of CSS files for my jQuery-ui version. To all of you that had a similar problem make sure you download the correct theme's version for your jQuery-ui scripts.
我的问题不在于 CSS 有效性或相对路径......我只是为我的 jQuery-ui 版本引用了错误版本的 CSS 文件。对于遇到类似问题的所有人,请确保为 jQuery-ui 脚本下载正确的主题版本。
Thanks.
谢谢。
回答by vkrams
I got the problem which is opposite of yours. Wherein i forgot to insert the below line in my head section and my datepicker is taking the css from my template. After including it in my head section, I can able to view the datetime picker with googleapi's css
我遇到了与你相反的问题。其中我忘记在我的头部部分插入以下行,而我的日期选择器正在从我的模板中获取 css。将它包含在我的 head 部分后,我可以使用 googleapi 的 css 查看日期时间选择器
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">
回答by Saiful Islam
let's try with this ...
让我们试试这个...
function eds_admin_styles() {
wp_enqueue_style( 'jquery-ui-datepicker-style' , '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css');
}
add_action('admin_print_styles', 'eds_admin_styles');
function eds_admin_scripts() {
wp_enqueue_script( 'jquery-ui-datepicker' );
}
add_action('admin_enqueue_scripts', 'eds_admin_scripts');
here is js
这是js
(function($) {
$('#jquery-datepicker').datepicker();
}(jQuery));