Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 闪亮:标签位置,文本输入_Css_R_Shiny_Styles - Fatal编程技术网

Css 闪亮:标签位置,文本输入

Css 闪亮:标签位置,文本输入,css,r,shiny,styles,Css,R,Shiny,Styles,让我们假设我有一个非常简单的应用程序,只有8个输入分组在2个面板中(4个输入| 4个输入-见下图),并基于这些,我绘制了一个小图(easy peasy) 我面临的问题是,我只希望第一个面板上有标签,并且标签位于textInput框的左侧 e、 (请原谅我草率的图像编辑!) 有什么建议吗 图1输出的MWE: library(shiny) ui<-shinyUI(fluidPage( wellPanel( tags$style(type="text/css", '#leftPa

让我们假设我有一个非常简单的应用程序,只有8个输入分组在2个面板中(4个输入| 4个输入-见下图),并基于这些,我绘制了一个小图(easy peasy)

我面临的问题是,我只希望第一个面板上有标签,并且标签位于
textInput
框的左侧

e、 (请原谅我草率的图像编辑!)

有什么建议吗

图1输出的MWE:

library(shiny)
ui<-shinyUI(fluidPage(
  wellPanel(
    tags$style(type="text/css", '#leftPanel { max-width:300px; float:left;}'),
    id = "leftPanel",
    textInput("Population1000", 'Population 1000',"15"),
    textInput("Area1000",'Area  1000', "20"),
    textInput("GNI1000", 'GNI 1000', "2314"),
    textInput("GDP1000", "GDP 1000", "1000")
  ),
  wellPanel(
    tags$style(type="text/css", '#RightPanel { max-width:300px; float:left;}'),
    id = "RightPanel",
    textInput("Population2000", 'Population 2000',"15"),
    textInput("Area2000",'Area 2000', "20"),
    textInput("GNI2000", 'GNI 2000', "2314"),
    textInput("GDP2000", "GDP 2000", "1000")
  )
)
)
server<-shinyServer(function(input, output) {NULL})
shinyApp(ui,server)
库(闪亮)

uiHi您可以尝试使用Bootstrap,看看下面的代码,它创建了3列,每列宽度为4。对于标签,您可以在
class=“col-sm-4控制标签”
中更改宽度;对于输入,您可以在
width=4
中更改宽度

library("shiny")
ui <- fluidPage(

  fluidRow(
    column(

      width = 4,

      tags$form(
        class="form-horizontal",

        tags$div(
          class="form-group",
          tags$label(class = "col-sm-4 control-label", `for` = "Population1000", br(), "Population"),
          column(width = 4, textInput(inputId = "Population1000", label = "Year 1000", value = "15")),
          column(width = 4, textInput(inputId = "Population2000", label = "Year 2000", value = "15"))
        ),

        tags$div(
          class="form-group",
          tags$label(class = "col-sm-4 control-label", `for` = "Area1000", "Area"),
          column(width = 4, textInput(inputId = "Area1000", label = NULL, value = "20")),
          column(width = 4, textInput(inputId = "Area2000", label = NULL, value = "20"))
        ),

        "..."

      )
    )
  )

)

server <- function(input, output) {

}

shinyApp(ui = ui, server = server)
库(“闪亮”)

ui Hi@Victorp,这确实是一个非常好的解决方案,但它并不能解决我的问题,因为我无法将我的条目分组到面板中,或者类似的东西。基本上,每列应代表一年(如1000、2000年),因此,应有一种方法来区分列(如标题)。(很抱歉没有在图片中显示得更清楚。我将进行更改)最简单的方法是在第一次输入中添加一个标签,并在左侧的标签中添加一个换行符。查看EditsUnderful,对其进行了测试,它以一种非常好的方式工作。