2012-01-26 32 views
1

我已經看到許多行上的答案 How to change the cell color of a jquery datepicker 但他們出於某種原因不適用於我的示例。正確的方式來更改日期選擇器上的特定日期的單元格背景顏色

http://plungjan.name/test/datepicker_orange.html

我想整個單元格的內容爲橙色,不正是我們能夠在細胞中的鏈接後面看到

所以,我所看到的是

.ui-state-default { 
    background: url("images/ui-bg_glass_75_e6e6e6_1x400.png") repeat-x scroll 50% 50% #E6E6E6; 
    border: 1px solid #D3D3D3; 
    color: #555555; 
    font-weight: normal; 
} 

控制單元格內的鏈接,類名由我設置爲「橙色」

<td class=" orange" onclick="DP_jQuery_1327604402271.datepicker._selectDay('#toDate',1,2012, this);return false;" title="Almost sold out"> 
<a class="ui-state-default" href="#">15</a> 
</td> 

,其中橙類是由我在此代碼給出:

return [true,"orange","Almost sold out"]; 

它顯示

enter image description here

,而不是

enter image description here

,我可以得到,如果我刪除上面的ui-state-default在firebug中的背景圖片

改變單元格的完整單元格顏色的正確方法是什麼我現在使用beforeShowDay進行更改?

我試圖通過覆蓋默認幫助的情況:

.ui-state-default { 
    background-color: transparent; 
    border: 1px solid #D3D3D3; 
    color: #555555; 
    font-weight: normal; 
} 

沒有做任何diffence

回答

3

@mplungjan更改CSS來此:

td.highlight {border: none !important;padding: 1px 0 1px 1px !important;background: none !important;overflow:hidden;} 
td.highlight a {background: #99dd73 url(bg.png) 50% 50% repeat-x !important; border: 1px #88a276 solid !important;} 
+0

謝謝!你能給我一個解釋,爲什麼這有效嗎? – mplungjan

+2

實際上這個選擇器有一個表格格式,可以像典型表格一樣生成代碼。每個td內都有一個標籤,其中包含日期編號和鏈接說明,以便您可以查看懸停時的提示。 現在它的工作原理是因爲默認的主題有一個BG圖像,我們的班級也需要一個BG圖像,而不僅僅是顏色。 – Mike

+0

有沒有辦法做到這一點爲「假」,所以它也不可選? –

0

如果直接把你的類的標籤,你必須把它改成這樣:

.ui-state-default { 
    background: #E6E6E6; 
    border: 1px solid #D3D3D3; 
    color: #555555; 
    font-weight: normal; 
} 

在CSS中,如果你有一個backgorund圖像和一個背景顏色,那麼瀏覽器會顯示你的圖像,在這種情況下是你在f第一個例子。

+0

沒有任何區別。試試吧 – mplungjan

相關問題