【问题标题】:How to change sidebar menuItem("menu1") font color in shinydashboard?如何更改闪亮仪表板中的侧边栏 menuItem("menu1") 字体颜色?
【发布时间】:2020-10-20 18:34:22
【问题描述】:

我正在尝试更改 shinydashboard 侧边栏中 menuItem() 的文本颜色,但我的代码不起作用。

我的代码:

library(shinydashboard)

ui <- shinyUI(dashboardPage(
          dashboardHeader(title = "a"),
          dashboardSidebar(
            tags$style(HTML(".sidebar-menu li a { font-size: 100px; }")), 
            
            menuItem("first"),
            menuItem("second")
          ),
          dashboardBody(
            tags$style(HTML(".sidebar-menu li a { font-size: 100px; }")),
            tags$head(tags$style(HTML('
            .skin-blue .sidebar-menu > li.active > a {
            color:#ccff00; background-color:#ffffff
            },
            .skin-black .main-sidebar ELEMENT {
            color: #ffccdd;}
            .skin-blue .sidebar-menu > li:hover > a {font-color : #ffdd00;
              border-left-color: #ff0000 ; background-color:#ffffff;
            }'
                                      ))),
            
            "HI"
            
          )))

server <- shinyServer(function(input,output){

})

shinyApp(ui,server)

对此的任何帮助都将非常感激。

【问题讨论】:

    标签: r shinydashboard


    【解决方案1】:

    我已经删除了您的一些样式代码,但这应该会产生所需的颜色结果:

    library(shiny)
    library(shinydashboard)
    
    ui <- shinyUI(dashboardPage(
        dashboardHeader(title = "a"),
        dashboardSidebar(
            tags$style(HTML(".sidebar-menu li a { font-size: 100px; }")), 
            
            menuItem("first"),
            menuItem("second")
        ),
        dashboardBody(
            tags$style(HTML(".sidebar-menu li a { font-size: 100px; }")),
            tags$head(tags$style(HTML('
                .skin-blue .sidebar a {
                    color: #ccff00;
                }'
            ))),
            
            "HI"
            
        )))
    
    server <- shinyServer(function(input,output){
        
    })
    
    shinyApp(ui,server)
    

    【讨论】:

    • 太棒了……!非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2016-11-11
    • 2018-11-27
    • 2020-07-07
    • 1970-01-01
    • 2015-11-18
    • 1970-01-01
    • 2015-10-21
    • 2017-12-14
    相关资源
    最近更新 更多