RShiny:如何使滑块居中 [英] RShiny: How to center sliders

查看:0
本文介绍了RShiny:如何使滑块居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,我正在尝试复制此模板:https://shiny.rstudio.com/gallery/retirement-simulation.html 我确实有此模板的代码,但这是一个学习练习。

以下是我到目前为止的情况:

ui <- fluidPage(

  # Title goes here...
  titlePanel("Retirement: simulating wealth with random returns, inflation and withdrawals"),
  p("Description here..."),
  hr(),

  # Sidebar layout...
  sidebarLayout(
    # Sidebar panel...
    sidebarPanel(
      # Input: Slider for the number of observations to generate ----
      sliderInput("n",
                  "Param 1",
                  value = 500,
                  min = 1,
                  max = 1000),
      sliderInput("n",
                  "Param 2",
                  value = 500,
                  min = 1,
                  max = 1000),
      sliderInput("n",
                  "Param 3",
                  value = 500,
                  min = 1,
                  max = 1000),
      sliderInput("n",
                  "Param 4",
                  value = 500,
                  min = 1,
                  max = 1000)
    ),

    # Main panel...
    mainPanel(
      # Outputs of any plots...
      tabsetPanel(type = "tabs",
                  tabPanel("Plot", plotOutput("plot"))
      )
    )
  )
)

看起来不错,但我需要滑块居中,就像上面的模板一样。非常感谢您给我们指明了正确的方向!

谢谢,

Joesph

推荐答案

使用margin: autocss规则:

div(style = "margin: auto; width: 80%", # this number can be any percentage you need
    sliderInput(
                ...
                width = "100%" # this number has to be "100%", nothing less
               )
   )

这篇关于RShiny:如何使滑块居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆