简体   繁体   English

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

[英]How do I eliminate stubborn white space between fluidRows in Shiny?

I have two fluidRows in a column of my UI in Shiny. 我在Shiny的UI列中有两个fluidRows。

I want the top row to have a slight space above it, but I want to eliminate any space between the rows . 我希望最上面的行上面有一点空间,但是我想消除行之间的任何空间

  • I've tried div , tags , and an assortment of style arguments like margin: 0px and padding: 0px ... , but I can't get the spacing to act accordingly. 我已经尝试了divtags和各种样式参数,例如margin: 0pxpadding: 0px ... ,但是我无法获得相应的间距。

    • Here's an example: 这是一个例子:

       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 = ">") ) ) ) ) ) 

What I get is this: 我得到的是:

在此处输入图片说明 (Notice the large [unwanted] space between rows) (请注意行之间较大的[不需要的]空间)

What I want is this: 我想要的是:

在此处输入图片说明 (Notice the significantly smaller space between rows) (请注意,行之间的空间要小得多)

How do I do this?? 我该怎么做呢??

You can use negative values on margin , in this case use margin-top:-2em to affect only the top margin. 您可以在margin上使用负值,在这种情况下,可以使用margin-top:-2em仅影响顶部边缘。 I prefer to use relative units, but you can use pixel instead of em . 我更喜欢使用相对单位,但是您可以使用pixel而不是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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM