如何在闪亮的情况下内嵌显示小部件

van*_*yan 21 r rstudio shiny shinydashboard

我有下面的代码来显示内联(在同一行)闪亮的小部件

div(style="display:inline-block; width: 150px;height: 75px;",selectInput("ddllgra", "Function:",c('mean','median','sd','count','min','max'), selected='mean')),
div(style="display:inline-block; width: 150px;height: 75px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))
Run Code Online (Sandbox Code Playgroud)

它在UI中出现,但不是以相同的行顺序出现.一个进入上方,另一个进入下方一条线.

有没有办法纠正这种错位?

Por*_*hop 27

加入vertical-align:top你的style

rm(list = ls())
library(shiny)

ui <- fluidPage(
    sidebarPanel(
          div(style="display: inline-block;vertical-align:top; width: 150px;",selectInput("ddllgra", "Function:",c('mean','median','sd','count','min','max'), selected='mean')),
          div(style="display: inline-block;vertical-align:top; width: 150px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))),
    mainPanel()
)
server <- shinyServer(function(input,output){})
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

编辑:如何在div之间添加空格

您可以使用相同的方法:下面的示例100px介于div之间

rm(list = ls())
library(shiny)

ui <- fluidPage(
  sidebarPanel(
    div(style="display: inline-block;vertical-align:top; width: 150px;",selectInput("ddllgra", "Function:",c('mean','median','sd','count','min','max'), selected='mean')),
    div(style="display: inline-block;vertical-align:top; width: 100px;",HTML("<br>")),
    div(style="display: inline-block;vertical-align:top; width: 150px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))),
  mainPanel()
)
server <- shinyServer(function(input,output){})
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


Ber*_*cht 18

您应该使用fluidRow创建一个fluidPage,然后使用列函数.

     fluidPage(fluidRow(
                        column(2, selectInput()),
                        column(1, selectInput()),
                        column(2, textInput())
                        )
               )
Run Code Online (Sandbox Code Playgroud)

更多细节,查看fluidPage,fluidRow和列内闪亮的函数引用:http://shiny.rstudio.com/reference/shiny/latest/