Javascript JQuery DatePicker 背景色

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

JQuery DatePicker background color

javascriptjquery

提问by Tony

I am using an example of JQuery DatePicker from link text

我正在使用链接文本中的 JQuery DatePicker 示例

on my asp.net page.

在我的 asp.net 页面上。

But, background color of the datepicker is white. I am not sure how to change this. (Change to default color) My asp.net page background page is white, maybe because of that?

但是,日期选择器的背景颜色是白色。我不知道如何改变这一点。(更改为默认颜色)我的asp.net 页面背景页面是白色的,可能是因为这个?

Any help would be appereicate it. Thanks.

任何帮助都会很高兴。谢谢。

回答by andynormancx

The background formatting for the control comes from the .ui-widget-contentCSS class. Assuming you only want to apply to the date picker and not other controls you want something like this:

控件的背景格式来自.ui-widget-contentCSS 类。假设您只想应用于日期选择器而不是其他控件,您需要这样的东西:

.ui-datepicker .ui-widget-content {
    background: #999 none;
}

If instead you want to change the background colour for all controls, just find the existing .ui-widget-contentclass in your CSS and change that.

相反,如果您想更改所有控件的背景颜色,只需.ui-widget-content在 CSS 中找到现有类并进行更改。

回答by the_haystacker

Just Add this one line of code into your jquery ui css file

只需将这一行代码添加到您的 jquery ui css 文件中

.ui-datepicker .ui-datepicker-title select{color: #000;}

This will solve your problem.

这将解决您的问题。

回答by Habib Rosyad

You can change the background color of DatePicker via the CSS file which come with the package. Locate for class selector .ui-widget-content, there should be background attribute which you can change to your liking.

您可以通过软件包附带的 CSS 文件更改 DatePicker 的背景颜色。找到 class selector .ui-widget-content,应该有背景属性,您可以根据自己的喜好进行更改。

回答by Tono Nam

with this function you can color the days you want:

使用此功能,您可以为您想要的日子着色:

$("#dater").datepicker({
    numberOfMonths: 3,   
});
function ColorDay(month, day, year, backgroundColor)
{
    day--;
    $("[onclick*='"+month+","+year+"'] [class*=ui-state-default]").eq(day).css("background",backgroundColor); 

}

then to color a day do:

然后为一天着色:

ColorDay(6,30,2012,"yellow"); // color July 30, 2012   of yellow

回答by sucket

How about try this code

试试这个代码怎么样

 a.ui-state-default{
   background-color: red !important;
 }