简体   繁体   English

如何在 R Shiny 中更改 titlePanel 的背景颜色和文本颜色?

[英]How to change background color and text color of a titlePanel in R Shiny?

I'm having trouble changing the background color and text color in my Shiny dashboard and the videos and sites that I've looked at have been no help as what they say to do is giving me an error.我在更改 Shiny 仪表板中的背景颜色和文本颜色时遇到了问题,而且我看过的视频和网站也没有任何帮助,因为他们说要做的就是给我一个错误。 My code is:我的代码是:

ui <- fluidPage(
  titlePanel(HTML("<center>This Is My Title</center>"),
             tags$style(
                background-color: "blue",
                color: "white")
))

As you can see, I am trying to make the text color white and the background for only the title to be blue.如您所见,我正在尝试将文本颜色设为白色,并将仅标题的背景设为蓝色。 If anyone can help that would be much appreciated.如果有人可以提供帮助,将不胜感激。

titlePanel("This is my title")
tags$style(HTML("
    body {
            background-color: Black;
            color: white;
            }"))

You can use titlePanel to set your title in shiny instead of wrapping in HTML, and then for the CSS, it needs to be completely wrapped by HTML() and Quotes for it to work.您可以使用 titlePanel 将您的标题设置为闪亮而不是包装在 HTML 中,然后对于 CSS,它需要完全由 HTML() 和 Quotes 包装才能工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM