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

时间:2016-04-19 05:36:18

标签: r shiny rstudio 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))

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

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

2 个答案:

答案 0 :(得分:25)

Option Explicit Sub Obj_Fnc_Colmn() Dim IN1 As Range, OP1 As Range Dim X_Var As String, Y_Var As String Set IN1 = Sheets("Sheet1").Cells(2, 4) Set OP1 = Sheets("Sheet1").Cells(2, 5) X_Var = Split(IN1.Address(external:=True), "[")(0) & Split(IN1.Address(external:=True), "]")(1) Y_Var = Split(OP1.Address(external:=True), "[")(0) & Split(OP1.Address(external:=True), "]")(1) SolverOK SetCell:=Y_Var, MaxMinVal:=3, ValueOf:=0, ByChange:=X_Var, Engine:=1 SolverAdd CellRef:=X_Var, Relation:=3, FormulaText:=0 SolverSolve UserFinish:=True End Sub 添加到您的vertical-align:top

style

enter image description here

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

您可以使用相同的方法:下面的示例在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: 150px;",textInput(inputId="xlimitsmax", label="x-max", value = 0.5))), mainPanel() ) server <- shinyServer(function(input,output){}) shinyApp(ui, server)

100px

enter image description here

答案 1 :(得分:15)

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

     fluidPage(fluidRow(
                        column(2, selectInput()),
                        column(1, selectInput()),
                        column(2, textInput())
                        )
               )

更多细节,查看有光泽的函数引用中的fluidPage,fluidRow和column: http://shiny.rstudio.com/reference/shiny/latest/