将不同的 CSS 样式应用于 R Shiny 中的框元素
我有一个应用程序,我希望 main_box 展开/收缩图标为白色背景的黑色文本,然后 sub_box 的选项框以红色和白色字母显示。此外,我希望子框的选项框保持红色和白色字母,即使将鼠标悬停在上面或单击时也是如此。
我能够正确实现 sub_box css,但我不知道如何从 main_box css 中分离 sub_box css。谁能告诉我我做错了什么?
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
tags$style(HTML("
.box.box-solid > .box-header > .box-tools .btn {
background: #fd0000;
color: #ffffff;
}
")),
box(title = "main_box", collapsible = T,
box(title = "sub_box",
dropdownMenu = dropdown(label = "Options",
"Hello World!")
)
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)
当前状态:
所需的最终状态:
I have an app in which I would like the main_box expand/contract icon to be in black text with a white background, and then the sub_box's options box to appear in red with white letters. Additionally, I want the sub_box's options box to remain red w/ white letters, even when hovered over or clicked.
I'm able to get the sub_box css implemented correctly, but I can't figure out how to disaggregate the sub_box css from the main_box css. Can anyone tell me what I'm doing wrong?
library(shiny)
library(shinydashboard)
library(shinyWidgets)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
tags$style(HTML("
.box.box-solid > .box-header > .box-tools .btn {
background: #fd0000;
color: #ffffff;
}
")),
box(title = "main_box", collapsible = T,
box(title = "sub_box",
dropdownMenu = dropdown(label = "Options",
"Hello World!")
)
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)
Current State:
Desired End State:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
区分这些框的一个简单方法是为它们提供
id
- 请参阅以下内容:此外,请确保解决命名空间问题。
shinydashboard::box
没有dropdownMenu
参数 -shinydashboardPlus::box
有。A simple way to distinguish those boxes is to provide them with an
id
- please see the following:Furthermore please make sure to address namespace issues.
shinydashboard::box
does not have adropdownMenu
parameter -shinydashboardPlus::box
has.