在fluidrow中将逐字文本输出与文本输入对齐- R Shiny

ki1q1bka  于 2023-01-28  发布在  其他
关注(0)|答案(1)|浏览(77)

我试图显示一些输入字段旁边的一些输出字段从另一个标签输入。但输出字段是去下面,不能与其余对齐。
代码如下:-

fluidRow(
  column(3, sliderInput(inputId = "avg_planned_miles", label = "Average Planner Miles", min = 5, max = 50, value = 9, step = 0.1)),
  column(3, textInput(inputId = "batch_pct", label = "Batch %", value = "0.5")),
  column(3, h4("Volume: "), verbatimTextOutput(outputId = "planner_volume"))
)

4nkexdtk

4nkexdtk1#

试试这个代码,我觉得它看起来更好

fluidRow(
  column(3,
         tagList(
           tags$style(type = 'text/css','#avg_planned_miles .irs-grid-text {font-size: 12px}'), #the grid numbers size
           div(id = 'avg_planned_miles', style='font-size: 16px;', #label font size
               sliderInput(inputId = "avg_planned_miles", label = "Average Planner Miles\n", min = 5, max = 50, value = 9, step = 0.1)
           )#div
         )#tags
  ),
  column(3,
         tagList(
           div(id = 'batch_pct',
               style='position:absolute; top:10px; right:5px;', #add margin space 
               textInput(inputId = "batch_pct", width = 280,
                         label = "Batch%", value = "0.5")
           )
         )
  ),
  column(3, p(strong("Volume")), #bold font to match the other fields
         verbatimTextOutput(outputId = "planner_volume", placeholder = 1)
  ),
)

你可以保持sliderInput在你的代码中的样子,我想如果字体大小更大,它会对齐得更好。

相关问题