r - 增加 Shiny 仪表板中侧标签和 Shiny 小部件之间的距离

标签 r shiny

如何增加 Shiny 仪表板中标签和输入之间的距离?

library(shiny)

ui <- shinyUI(
  pageWithSidebar( 
    
    headerPanel("side-by-side"), 
    
    sidebarPanel(
      fluidRow(
        tags$head(
          tags$style(type="text/css", "label.control-label, .selectize-control.single{ display: table-cell; text-align: center; vertical-align: middle; } .form-group { display: table-row;}")
        ),
        column(2),
        column(4,
               selectInput(inputId = "options", label = "some text", 
                           choices = list(a = 0, b = 1))
        )
      )),
    mainPanel(
      fluidRow( 
        h3("bla bla")
      ))
  )
)
server <- shinyServer(function(input, output) { NULL })
shinyApp(ui = ui, server = server)

最佳答案

尝试在 selectInput 之前添加此行,并确保在 selectInput 之后添加额外的括号以关闭 tags$div

tags$div(id = "div_test", tags$style("#div_test div {margin-left: 20px}")

所以会是:

column(4,
       tags$div(id = "div_test", tags$style("#div_test div {margin-left: 20px}"),

       selectInput(inputId = "options", label = "some text", 
                   choices = list(a = 0, b = 1))),
)

基本上,它的作用是在 selectInput 之前创建一个额外的 div,我们将使用它来缩进以增加标签和选择输入之间的间距。

enter image description here

关于r - 增加 Shiny 仪表板中侧标签和 Shiny 小部件之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67259664/

相关文章:

r - 如何更改 ggplot2 R 中 stat_poly_eq 的字体大小

r - 如何在 R 中使用相对路径从 mac 上的目录读取数据?

html - 折叠大宽度的 Shiny Dashboard 侧边栏

r - 发生错误时避免关闭 Shiny 浏览器

r - 更改将鼠标悬停在绘图中的值上

r - 是否将任意R对象存储到HDD?

function - R 存在函数吗?

r - 在 R 中找到矩阵的相邻元素

R Shiny : How to have sequential Modals in for loop

css - 更改 textInput Shiny 小部件的占位符颜色