jQuery datepicker 上一个和下一个按钮未显示,如何在 css 中指向主题文件夹图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18422154/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 21:35:38  来源:igfitidea点击:

jQuery datepicker prev and next buttons not showing, how to point at theme folder images in css

javascriptjqueryjquery-uidatepicker

提问by Jay

I have used the jQuery ui datepicker to successfully add a calendar control to my textbox, but the previous and next buttons are not visible although the containing tag works functionally when clicking

我已经使用 jQuery ui datepicker 成功地将日历控件添加到我的文本框,但上一个和下一个按钮不可见,尽管包含标签在单击时可以正常工作

The how can I modify this to show the icons shown on the http://jqueryui.com/datepicker/when these images are found within my web package at ..\Content\theme\base\images and not the locations shown below

当这些图像在我的 web 包中的 ..\Content\theme\base\images 而不是下面显示的位置时,我如何修改它以显示http://jqueryui.com/datepicker/上显示的图标

.ui-widget-content .ui-icon {
background-image: url(images/ui-icons_222222_256x240.png);
}
.ui-widget-header .ui-icon {
background-image: url(images/ui-icons_222222_256x240.png);
}

Do I need to call the image within css in a similar fashion to how images are called from within my c# code? As in:

我是否需要以类似于在我的 c# 代码中调用图像的方式在 css 中调用图像?如:

"@Url.Content("~/Content/theme/base/images/ui-icons_222222_256x240.png")"

回答by Mooseman

Make sure your jquery-ui.min.cssis pointing to the correct file for the images. The console should show an error when you are attempting to load the icons.

确保您jquery-ui.min.css指向正确的图像文件。当您尝试加载图标时,控制台应显示错误。

For example, If this is the location of your CSS file: http://example.com/css/jquery-ui.min.css, then the icon file should be in http://example.com/css/images/ui-icons_222222_256x240.png. The link in the CSS file is relative to the CSS file, not the HTML file loading it.

例如,如果这是您的 CSS 文件的位置:http://example.com/css/jquery-ui.min.css,那么图标文件应该在http://example.com/css/images/ui-icons_222222_256x240.png. CSS 文件中的链接是相对于 CSS 文件的,而不是加载它的 HTML 文件。

回答by Francois Muller

You are almost there.

你快到了。

Just ensure you change your url and add the "!important" at the end of the line.

只需确保更改您的网址并在行尾添加“!important”即可。

This will allow you to add any image you wish.

这将允许您添加任何您想要的图像。

    .ui-widget-content .ui-icon {
    background-image: url("../../images/ui-icons_222222_256x240.png")      
    !important;}
    .ui-widget-header .ui-icon {
    background-image: url("../../images/ui-icons_222222_256x240.png")   
    !important;}

Hope this works for you.

希望这对你有用。

回答by Bassie

I noticed from the error message that the site was looking in:

我从该网站正在查看的错误消息中注意到:

http://site/Content/images/image.png

http://site/Content/images/image.png

I'm not quite sure why, as from Mooseman's answer:

我不太确定为什么,正如穆斯曼的回答:

The link in the CSS file is relative to the CSS file, not the HTML file loading it.

CSS 文件中的链接是相对于 CSS 文件的,而不是加载它的 HTML 文件。

It seems that the link was relative from site.css(which is contained in Content) rather than Jquery-ui.mincss, and so it obviously could not find the png.

似乎该链接是相对于site.css(包含在 中Content)而不是 的Jquery-ui.mincss,因此它显然找不到 png。

After changing the paths in JQuery-ui.min.cssto

将路径更改JQuery-ui.min.css

themes/base/images/image.png

themes/base/images/image.png

It now works perfectly.

它现在可以完美运行。

回答by Huzaif Sayyed

This is because you are mission ui-icons_444444_256x240.pngimage. You can Download that image from here link.

这是因为你是使命ui-icons_444444_256x240.png形象。您可以从这里链接下载该图像。

Now create a folder named - imagesand add that folder image inside that folder.

现在创建一个名为 - 的文件夹images并将该文件夹图像添加到该文件夹​​中。

Example

例子

http://example.com/css/jquery-ui.min.css
http://example.com/css/images/ui-icons_444444_256x240.png

回答by Underwaters

For anyone looking for the most simple answer,

对于任何寻找最简单答案的人,

  1. Go to the site JQuery UIand download the file with default settings.
  2. Extract the file.
  3. Copy the "images" folder and put it in you project in the same folder where the jQuery ui css resides and that will take care the problem.
  1. 转到站点JQuery UI并使用默认设置下载文件。
  2. 提取文件。
  3. 复制“图像”文件夹并将其放入您的项目中 jQuery ui css 所在的同一文件夹中,这将解决问题。

Credits to Gullele's Corner, I just simply updated the procedure since the folder structure change (May 2019).

感谢Gullele's Corner,自文件夹结构更改(2019 年 5 月)以来,我只是简单地更新了程序。