gpt4 book ai didi

css - Shiny - 更改文本(框)的大小、颜色和字体

转载 作者:行者123 更新时间:2023-12-02 00:42:36 26 4
gpt4 key购买 nike

这一定是一个简单的问题,但我还没有找到任何关于更改 shinyDashboard 框中文本的大小、字体和颜色的脚本或建议。比方说,我想让这个框显示 14px Arial 灰色文本:

  box(width = 4, title = "sample", "this is a test")

我想这需要 css,但是有什么方法可以使用 Shiny 的内置函数来实现吗?

非常感谢。

最佳答案

您需要更改框的 CSS 才能使其正常工作。您可以使用 tableHTML::make_css 直接在 ui 中传递 CSS。函数 box 创建一个名为“box”的 HTML 类,您可以使用它来更改框的 CSS:

library(shiny)
library(tableHTML)

ui <- fluidPage(
tags$style(make_css(list('.box',
c('font-size', 'font-family', 'color'),
c('14px', 'arial', 'red')))),
box(width = 4, title = "sample", "this is a test")
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

输出:

我将文字设为红色,这样您就可以很容易地分辨出黑色。您可以将其替换为灰色或您想要的任何颜色。

enter image description here

关于css - Shiny - 更改文本(框)的大小、颜色和字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45690184/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com