你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

huangapple go评论105阅读模式
英文:

How can I change the font color of an accordion menu in a shiny app?

问题

I want to recreate the following accordion menu:
你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am using the accordion() function from the shinydashboardPlus package, and got to here so far:
你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am trying to change the font color to black to match the first image, but adding the following CSS code is not working:

  1. tags$head(
  2. tags$style(
  3. HTML(".box-title {
  4. color: black !important;
  5. }")
  6. )
  7. )

If someone could help me to change the font color, and if possible to add the well (AKA: the white rectangle with circled borders around each item of the accordion menu) it would be great!

Here is the full app code:

  1. library(shiny)
  2. library(shinydashboard)
  3. library(shinydashboardPlus)
  4. ui <- fluidPage(
  5. tags$head(
  6. tags$style(
  7. HTML(".box-title {
  8. color: black !important;
  9. }")
  10. )
  11. ),
  12. accordion(
  13. id = "covenants",
  14. accordionItem(
  15. title = "Cash on cash",
  16. status = "danger",
  17. collapsed = TRUE,
  18. "This is some text!"
  19. ),
  20. accordionItem(
  21. title = "Net Portfolio Yield Percentage",
  22. status = "warning",
  23. collapsed = TRUE,
  24. "This is some text!"
  25. ),
  26. accordionItem(
  27. title = "Minimum Liquidity Amount",
  28. status = "warning",
  29. collapsed = TRUE,
  30. "This is some text!"
  31. ),
  32. accordionItem(
  33. title = "Maximum Debt to Equity Ratio",
  34. status = "warning",
  35. collapsed = TRUE,
  36. "This is some text!"
  37. ),
  38. accordionItem(
  39. title = "Most Favored Nation",
  40. status = "warning",
  41. collapsed = TRUE,
  42. "This is some text!"
  43. )
  44. )
  45. )
  46. server <- function(input, output, session) {}
  47. shinyApp(ui, server)
英文:

I want to recreate the following accordion menu: 你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am using the accordion() function from the shinydashboardPlus package, and got to here so far:

你可以如何更改在闪亮应用程序中手风琴菜单的字体颜色?

I am trying to change the font color to black to match the first image, but adding the following CSS code is not working:

  1. tags$head(
  2. tags$style(
  3. HTML(&quot;
  4. .box-title {
  5. color: black !important;
  6. }
  7. &quot;)
  8. )
  9. )

If someone could help me to change the font color, and if possible to add the well (AKA: the white rectangle with circled borders around each item of the accordion menu) it would be great!

Here is te full app code:

  1. library(shiny)
  2. library(shinydashboard)
  3. library(shinydashboardPlus)
  4. ui &lt;- fluidPage(
  5. tags$head(
  6. tags$style(
  7. HTML(&quot;
  8. .box-title {
  9. color: black !important;
  10. }
  11. &quot;)
  12. )
  13. ),
  14. accordion(
  15. id = &quot;covenants&quot;,
  16. accordionItem(
  17. title = &quot;Cash on cash&quot;,
  18. status = &quot;danger&quot;,
  19. collapsed = TRUE,
  20. &quot;This is some text!&quot;
  21. ),
  22. accordionItem(
  23. title = &quot;Net Portfolio Yield Percentage&quot;,
  24. status = &quot;warning&quot;,
  25. collapsed = TRUE,
  26. &quot;This is some text!&quot;
  27. ),
  28. accordionItem(
  29. title = &quot;Minimum Liquidity Amount&quot;,
  30. status = &quot;warning&quot;,
  31. collapsed = TRUE,
  32. &quot;This is some text!&quot;
  33. ),
  34. accordionItem(
  35. title = &quot;Maximum Debt to Equity Ratio&quot;,
  36. status = &quot;warning&quot;,
  37. collapsed = TRUE,
  38. &quot;This is some text!&quot;
  39. ),
  40. accordionItem(
  41. title = &quot;Most Favored Nation&quot;,
  42. status = &quot;warning&quot;,
  43. collapsed = TRUE,
  44. &quot;This is some text!&quot;
  45. )
  46. )
  47. )
  48. server &lt;- function(input, output, session) {}
  49. shinyApp(ui, server)

答案1

得分: 0

.box-title选择器针对手风琴的标题,通常是一个超链接。默认情况下,超链接具有特殊样式,包括不同颜色的已访问和未访问链接。color属性仅适用于未访问链接,而:visited选择器可用于定位已访问链接。

因此,正确的CSS代码是:

  1. .box-title a {
  2. color: black !important;
  3. }
英文:

The .box-title selector targets the title of the accordion, which is usually a hyperlink. By default, hyperlinks have a special style that includes a different color for visited and unvisited links. The color property only applies to unvisited links, whereas the :visited selector can be used to target visited links

Therefore, the correct CSS code is:

  1. .box-title a {
  2. color: black !important;
  3. }

huangapple
  • 本文由 发表于 2023年4月11日 01:18:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75979190.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定