【问题标题】:Extra line between fileInput and checkboxInput in R ShinyR Shiny中fileInput和checkboxInput之间的额外行
【发布时间】:2017-07-23 00:15:47
【问题描述】:

看起来在 Shiny 中的 fileInput 和 checkboxInput 之间有一个额外的空格(即使我没有添加额外的行)。我如何摆脱那条额外的线?谢谢!

if (interactive()) {

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      fileInput("file1", "Choose CSV File",
        accept = c(
          "text/csv",
          "text/comma-separated-values,text/plain",
          ".csv")
        ),
      checkboxInput("header", "Header", TRUE)
    ),
    mainPanel(
      tableOutput("contents")
    )
  )
)

server <- function(input, output) {
  output$contents <- renderTable({
    inFile <- input$file1    
    if (is.null(inFile))
      return(NULL)    
    read.csv(inFile$datapath, header = input$header)
  })
}

shinyApp(ui, server)
}

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    嗯,这是进度条的空间。您可以使用 CSS 移除周围元素的边距,方法是加载包 shinyjs 并将其插入 UI 中的任何位置:

    inlineCSS(list(".shiny-input-container" = "margin-bottom: 0px", 
                   "#file1_progress" = "margin-bottom: 0px", 
                   ".checkbox" = "margin-top: 0px"))
    

    或者,如果你想在没有额外包的情况下做原生 CSS:

          tags$style(".shiny-input-container {margin-bottom: 0px} #file1_progress { margin-bottom: 0px } .checkbox { margin-top: 0px}"),
    

    提示:右键单击要删除的空间并选择“检查元素”。然后您可以查看该空间属于 HTML 的哪个节点。

    【讨论】:

      猜你喜欢
      • 2021-10-06
      • 1970-01-01
      • 2013-11-15
      • 2016-01-12
      • 2018-02-02
      • 1970-01-01
      • 2014-10-09
      • 2020-12-24
      • 2020-10-19
      相关资源
      最近更新 更多