2012-04-24 131 views
2

我需要星期日以紅色突出顯示。jQuery UI datepicker:如何爲星期日着色紅色?

我知道有一個類叫做ui-datepicker-week-end

我的問題是,即使設置了!important,其他類(ui-widget-contentui-state-default)也會覆蓋ui-datepicker-week-end的紅色。

唯一有顏色的是日曆標題中的週末日。

回答

5

您可以設置.ui-datepicker-week-end元素的後代的錨點,並在添加背景色時將其background-image屬性設置爲none。這給了良好的效果,您無需使用!important

.ui-datepicker-week-end a { 
    background-image: none; 
    background-color: red; 
} 

編輯:如果你想設置的color屬性,而不是background-color,你確實需要使用!important

.ui-datepicker-week-end a { 
    color: red !important; 
} 

你可以在this fiddle中看到結果。

+0

謝謝您的回答。但它仍然被覆蓋。請看F12開發者工具的截圖:http://img0.www.suckmypic.net/img/g/X/rwFhrsfy/jquery-ui-calendar.png – 2012-04-24 08:28:08

+0

道歉,我以爲你想設置'背景顏色'而不是'顏色'。但是,''important'在與'color'一起使用時在我的測試中起作用。我會更新我的答案。 – 2012-04-24 08:33:30

+0

你是對的,謝謝。 – 2012-04-24 08:35:27

0

簡單的方法

週日色紅這樣

.datepicker table tr td:first-child { 
color: red 
} 

週一紅色這樣

.datepicker table tr td:first-child +td { 
color: red 
} 

thuesday紅色這樣

.datepicker table tr td:first-child + td + td { 
color: red 
} 
相關問題