代码之家  ›  专栏  ›  技术社区  ›  Lilyzeng

如何更改r中textAreaInput的背景色?

  •  2
  • Lilyzeng  · 技术社区  · 7 年前

    我用过 textAreaInput() 在里面 dashboardHeader 允许标题中有多行。但是这个文本区域的背景色是白色的,无法融入那里的标题面板。我想将此文本区域的背景色更改为透明或与中使用的颜色相同 仪表板标题 . 我试过下面这样的方法。但它不起作用。有什么建议吗?非常感谢。

    library(shiny)
    library(shinydashboard)
    
    shinyApp(server = function(input, output) {}, ui = 
    
    dashboardPage(skin = "blue",
    
    dashboardHeader(
        title = textAreaInput(inputId = 'header',label = NULL, 
                              width = 250, height = 100,
                              value = "This is a very very very very very loooooong title"
                          ),
        titleWidth = 260
    ),
    
    dashboardSidebar(
        width = 260,     
        sidebarMenu(
           menuItem("About", tabName = "about", icon = icon("circle")),
           menuItem("References", tabName = "ref", icon = icon("book"))
         )
    ),
    
    dashboardBody(
    
        tags$head(tags$style(HTML('
               .textArea {
                  background-color: #0000ff;
                  border: none;
                }
         '))),
    
        tabItems(
            tabItem(tabName = 'about'),
            tabItem(tabName = 'ref')
        )
    )
    ))
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   Bertil Baron    7 年前

    嗨,你有两个选择

    如果要更改每个textArea的backgrondcolor,请首先选择一个。我需要删除textArea之前的点,因为它是一个标记,而不是类。前面的点告诉标识符查找类。然后你需要添加!这样的颜色之后很重要。

    tags$head(tags$style(HTML('
       textArea {
         background-color: #0000ff !important;
         border: none;
       }')))
    

    第二个问题是,如果您只想更改此特定文本的背景色,那么最好使用id #header 在这种情况下,你不需要 !important

    tags$head(tags$style(HTML('
      #header{
        background-color: #0000ff !important;
        border: none;
        }')))
    

    希望这有帮助!