1)我们如何将selectInput放置在另一个位置上?我试过:
# style.css
.general {
display: inline-block;
margin-left: auto;
margin-right: auto;
height: auto;
width : auto ;
white-space: nowrap ;}
# ui.R
...
tags$div(class = "general", selectInput(...), selectInput(...))
...但不起作用。
2)如何将selectInput的标签放置在selectInput本身旁边?我找到了这个主题Positioning Shiny widgets beside their headers,但这是为应用程序的所有selectInput设计的。我没有成功地将tags$style(...)中提供的代码仅用于我的应用程序的一个selectInput,而不是所有的selectInput。我们怎么能做到呢?
谢谢。
发布于 2016-01-06 18:45:37
(我回答问题1),举一个简单的例子:
# style.css
.divleft {
float : left;
width : 50%;
}
.clearl {
clear: left;
}
# ui.R
library(shiny)
shinyUI(fluidPage(
tagList(
tags$head(
tags$link(rel="stylesheet", type="text/css",href="style.css")
)
),
sidebarLayout(
sidebarPanel(
selectInput("s1", "Select 1", 1:10),
tags$div(
tags$div(class = "divleft", selectInput("s2", label = "Select 2", 1:5, width = validateCssUnit("70%"))),
tags$div(class = "divleft", selectInput("s3", label = "Select 3", 1:5, width = validateCssUnit("70%")))
),
tags$div(class = "clearl",
selectInput("s4", "Select 4", 1:5)
)
, width = 3),
mainPanel(
h3("Example")
)
)
)
)
# server.R
shinyServer(function(input, output, session) { })发布于 2016-06-09 11:37:16
只需尝试使用一个流体行和几个列。由于总流体行宽度= 12,您可以一个接一个地放置12列,而不需要任何额外的css。例如:
fluidRow(
column(6, selectInput("S1", label = "S1")),
column(6, selectInput("S2", label = "S2"))
)https://stackoverflow.com/questions/34211163
复制相似问题