gpt4 book ai didi

r - Shiny - 如何更改选定标签中的字体大小?

转载 作者:行者123 更新时间:2023-12-04 01:41:48 29 4
gpt4 key购买 nike

如何更改选定标签中的字体大小?

我尝试使用下面的代码,但字体大小根本没有改变。

shinyUI(fluidPage(

sidebarPanel(

# Change the font size.
tags$style(type='text/css', "select {font-size: 32px !important} "),

# Species/ pollutant options
selectInput(
inputId = "species",
label = "Species:",
choices = c(...)
),
....

有任何想法吗?

最佳答案

您的想法是正确的,但 Shiny 中的 select 输入实际上使用 selectize JavaScript 来显示 UI,而不是传统的 select HTML 标签。这就是为什么您的 CSS 没有被捕获的原因。

你想要什么而不是 select CSS 是 ".selectize-input { font-size: 32px; }
但是,如果您只有该 CSS,那么下拉菜单选项仍将是默认大小,并且文本周围也没有填充,这看起来很尴尬。以下是您可能想要使用的一些 CSS:

.selectize-input { font-size: 32px; line-height: 32px;}
.selectize-dropdown { font-size: 28px; line-height: 28px; }

因此,将其添加到应用程序中可以得到:
runApp(shinyApp(
ui = fluidPage(
tags$style(type='text/css', ".selectize-input { font-size: 32px; line-height: 32px;} .selectize-dropdown { font-size: 28px; line-height: 28px; }"),
selectInput("test","Test", 1:5)
),
server = function(input, output, session) {
}
))

关于r - Shiny - 如何更改选定标签中的字体大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30522279/

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