如何消除 Shiny 中的 fluidRows 之间的顽固空白?

the*_*ist 6 html css whitespace r shiny

我在 Shiny 的 UI 列中有两个fluidRows。

我希望顶行上方有一点空间,但我想消除行之间的任何空间

  • 我已经尝试过div, tags, 和各种各样的样式参数,比如margin: 0pxand padding: 0px ...,但我无法得到相应的间距。

    • 下面是一个例子:

      ui <- fluidPage(
      fluidRow(
      column(1,offset=0,
             div(style = "font-size: 10px; padding: 14px 0px; margin:0%",
                 fluidRow(
                   sliderInput(inputId = "sizeSlide", label = "Sizing", value = 10, min = 1,max = 20)
                 )
             ),
             div(style = "font-size: 10px; padding: 0px 0px; margin:0px", 
                 fluidRow(
                   radioButtons(inputId = "greatORless", label = "DBH Limiter", choices = c(">", "<"), selected = ">")
                 )                                      
             )
          )
        )
      )
      
      Run Code Online (Sandbox Code Playgroud)

我得到的是这样的:

在此处输入图片说明 (注意行之间的大 [不需要] 空间)

我想要的是这个:

在此处输入图片说明 (注意行之间的空间明显更小)

我该怎么做呢??

Geo*_*any 12

您可以在 上使用负值margin,在这种情况下margin-top:-2em仅用于影响顶部边距。我更喜欢使用相对单位,但您可以使用像素而不是em.

library(shiny)
ui <- fluidPage(
fluidRow(
column(1,offset=0,
       div(style = "font-size: 10px; padding: 14px 0px; margin:0%",
           fluidRow(
             sliderInput(inputId = "sizeSlide", label = "Sizing", value = 10, min = 1,max = 20)
           )
       ),
       div(style = "font-size: 10px; padding: 0px 0px; margin-top:-2em", 
           fluidRow(
             radioButtons(inputId = "greatORless", label = "DBH Limiter", choices = c(">", "<"), selected = ">")
           )                                      
       )
    )
  )
)

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)