簡體   English   中英

減小 sidebarPanel 中文本的字體大小

[英]Reduce the font size of the text within a sidebarPanel

我有以下代碼片段:

sidebarPanel(
    selectizeInput(
        "s1",
        "Select s1",
        choices = c('A', 'B'),
        multiple = FALSE
    ),
    radioButtons(
        "r1",
        "Select r1",
        choices = c("A", "B", "C")
    ),
    radioButtons(
        "r2",
        "Select r2",
        choices = c("P", "R")
    ),
    selectizeInput(
        "s3",
        "Select s3",
        choices = c('C', 'D'),
        multiple = FALSE
    ),
    selectizeInput(
        "s4",
        "Select s4",
        choices = c('A', 'B'),
        multiple = TRUE
    ),
    actionButton(
        "b1",
        "Enter"
    )
)

有沒有辦法減少這個sidebarPanel中包含的所有文本的字體大小,比如20%? 或者,我可以更改每個 selectizeInput 或 radioButtons 中的字體大小嗎?

您可以將其包裝在div中並使用style = "font-size:75%;"設置樣式 . 對於selectizeInput ,您需要對其不同的對象執行相同的操作,您可以通過 id 或整體使用.selectize-input { font-size: 75%;}

library(shiny)

ui <- fluidPage(
  tags$style(type='text/css', ".selectize-input { font-size: 75%;} .selectize-dropdown { font-size: 75%; }"),
  div(style = "font-size:75%;",
      sidebarPanel(
        selectizeInput(
          "s1",
          "Select s1",
          choices = c('A', 'B'),
          multiple = FALSE
        ),
        radioButtons(
          "r1",
          "Select r1",
          choices = c("A", "B", "C")
        ),
        radioButtons(
          "r2",
          "Select r2",
          choices = c("P", "R")
        ),
        selectizeInput(
          "s3",
          "Select s3",
          choices = c('C', 'D'),
          multiple = FALSE
        ),
        selectizeInput(
          "s4",
          "Select s4",
          choices = c('A', 'B'),
          multiple = TRUE
        ),
        actionButton(
          "b1",
          "Enter"
        )
      )
  )
)

server <- function(input, output, session){
  
}

shinyApp(ui, server)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM