簡體   English   中英

如何在TableView上正確覆蓋默認的JavaFX 8 CSS

[英]How to correctly override default JavaFX 8 CSS on TableView

我試圖覆蓋JavaFX的表格視圖中某些列的默認樣式。 基本上,我希望可編輯的值呈現淺黃色背景,以便人們知道這些列是可編輯的。

但是,當我在字段上設置此CSS時:

.editableColumn.table-cell { 
-fx-background-color:lightyellow;
-fx-alignment:CENTER-RIGHT;
-fx-border-width: .5px; 
-fx-border-style: solid;
-fx-border-color:grey;
}

它刪除了其余的格式,因此高亮條等都消失了。 在此處輸入圖片說明

我需要設置哪些CSS屬性以使突出顯示起作用,以便我的值不消失(此處為黃色的白色,因此您看不到該值)。

謝謝!

如果僅要確保文本顏色適合您設置的背景,請嘗試將-fx-background設置為與-fx-background-color相同的值:

.editableColumn.table-cell { 
-fx-background-color:lightyellow;
-fx-background: lightyellow ;
-fx-alignment:CENTER-RIGHT;
-fx-border-width: .5px; 
-fx-border-style: solid;
-fx-border-color:grey;
}

如果您希望“所選樣式”覆蓋列中和所選行中的單元格的“可編輯樣式”,我認為您將需要手動還原為所選單元格的默認樣式。 就像是

.table-row-cell:filled:selected .editableColumn.table-cell {
    -fx-background-color: null ;
    -fx-border-color: transparent -fx-table-cell-border-color transparent transparent;
    /* -fx-border-width: null ; (not sure about this one...) */
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM