css - 更改导航栏菜单的字体类型和背景颜色

标签 css r shiny

我有一个 Shiny 的应用程序,我想更改导航栏菜单的字体类型和背景颜色。 enter image description here

我在运行应用程序后对此使用了“检查”,我发现这个元素是:

a href="#" class="dropdown-toggle" data-toggle="dropdown" data-value="More">
                  More
                  <b class="caret"></b>
                </a>

但是我不熟悉css。

ui <- function(){

bootstrapPage('',

            navbarPage(title = 'Hello colour changed',
                       navbarMenu("More",
                                  tabPanel("Table"

                                  ),
                                  tabPanel("About"

                                  )
                       )),

            tags$style(type = 'text/css', '.navbar { background-color: #252525;
                       font-family: Arial;
                       font-size: 13px;
                       color: #FF0000; }',

                       '.navbar-dropdown { background-color: #252525;
                       font-family: Arial;
                       font-size: 13px;
                       color: #FF0000; }',

                       '.navbar-default .navbar-brand {
                       color: #cc3f3e;
            }'

            ))

            }

            server <- function(input, output, session){
            }


            shinyApp(ui = ui, server = server)

最佳答案

下面将更改导航栏的背景颜色、文本颜色,您还可以设置font-family来更改字体类型。

library(shiny)
library(shinydashboard)

ui <- function(){
  navbarPage(title = 'Hello colour change',
             tabPanel("title2"),
             tabPanel("title3"),

             tags$style(type = 'text/css', 
                        '.navbar { background-color: red;}',
                        '.navbar-default .navbar-brand{color: white;}',
                        '.tab-panel{ background-color: red; color: white}'

             ))
  }

server <- function(input, output, session){
}

shinyApp(ui = ui, server = server)

关于css - 更改导航栏菜单的字体类型和背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58651296/

相关文章:

css - 下拉列表中的破折号键入文本样式

html - flexbox 中的统一汽车元素高度

r - curl 命令在 Mac 和 Windows 上的行为不同

r - 从 varImp 中提取预测变量名称

r - 如何使用 Iframe 标记在 SharePoint 上嵌入 Shiny 的应用程序

html - CSS:过渡不适用于悬停

css - Font Awesome 图标 fa-undo-circle

debugging - Emacs Speaks Statistics 能否像真正的调试器一样通过 R for 循环进行循环?

html - 为所有页面应用背景颜色,包括 Shiny 中的导航栏

r - for 循环 Shiny 变量赋值