css - 突出显示 R Reactable 已经具有默认背景标题样式的排序标题?
问题描述
从这里(请参阅突出显示已排序的标题)我了解如何突出显示已排序的标题。如果标题已经有背景颜色,是否可以修改此方法以突出显示已排序的标题列?
突出显示排序的标题 - 无默认背景底纹(作品)
library(shiny)
library(reactable)
ui <- fluidPage(
theme = "test.css",
reactableOutput("table")
)
server <- function(input, output, session) {
output$table <- renderReactable({
reactable(iris,
defaultColDef = colDef(
# Use css to style the header of the sorted column
headerClass = "sort-header")
)
})
}
shinyApp(ui, server)
突出显示已排序的标题 - 使用默认背景底纹(失败)
library(shiny)
library(reactable)
ui <- fluidPage(
theme = "test.css",
reactableOutput("table")
)
server <- function(input, output, session) {
output$table <- renderReactable({
reactable(iris,
defaultColDef = colDef(
headerStyle = list(background = "#00FF00"),
# Use css to style the header of the sorted column
headerClass = "sort-header")
)
})
}
shinyApp(ui, server)
测试.css
.sort-header[aria-sort="ascending"],
.sort-header[aria-sort="descending"] {
background: rgba(255, 0, 0, 1);
}
解决方案
由 Reactable 的作者在这里回答
确保默认样式和排序样式的 css 具有相同的优先级。
R 脚本
ui <- fluidPage(
includeCSS("sort_column.css"),
reactableOutput("table")
)
server <- function(input, output, session) {
output$table <- renderReactable({
reactable(
iris[1:5, ],
defaultColDef = colDef(headerClass = "table-header"),
bordered = TRUE
)
})
}
shinyApp(ui, server)
排序列.css
/* Header style: Unsorted */
.table-header {
background: rgba(0, 100, 0, 1);
}
/* Header style: Sorted */
.table-header[aria-sort="ascending"],
.table-header[aria-sort="descending"] {
background: rgba(100, 0, 0, 1);
}
推荐阅读
- mysql - 如何编辑 Mysql innodb_autoinc_lock_mode 值
- javascript - .如何从windows手动卸载旧版本的npm for create-react app
- java - 使用 org.threeten.bp.format.DateTimeFormatter 解析多个模式
- php - 在 Flexslider 2 中使用高级自定义字段需要帮助
- git - jenkins:临时 git checkout other branch 导致触发提交的哈希不正确
- javascript - (Angular/Typescript) 不能使用变量来访问 JSON 对象
- r - 如何将 NA 移动到 R data.frame 列的顶部?
- javascript - Javascript 过滤来自 Firestore 的数据
- python - 根据用户输入访问类变量
- html - 如何在输入框前面添加文字