我在带有目录的rmarkdown文档中有一个闪亮的应用程序,但是一旦存在toc,应排在一行的fluidrow()元素就不再是一行,而与列宽的值无关:>
---
title: "Test column with toc"
output:
html_document:
theme: united
toc: yes
toc_float: yes
runtime: shiny
---
## headline
Fluidrow won't be in one row:
```{r, echo=FALSE}
library(shiny)
ui <- fluidPage(fluidRow(column(2,
sliderInput(
"obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500,
width = "20%"
)
),
column(2,
plotOutput("distPlot", width = "60%"))))
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
shinyApp(ui, server)
```
答案 0 :(得分:0)
根据窗口大小,默认情况下,列将使用类col-sm-2
更改为以768px的宽度堆叠。是引导程序类(https://getbootstrap.com/docs/3.3/css/#grid-options)。但是,如果您想要不同的行为,则可以使用div并将其赋予类col-xs-2
,以便将屏幕分成两半,即为div( class = "col-xs-6", ...)
以下是您可以执行的操作示例:
Fluidrow won't be in one row:
```{r, echo=FALSE}
library(shiny)
ui <- fluidPage(
fluidRow(
div( class = "col-xs-6",
sliderInput(
"obs",
"Number of observations:",
min = 1,
max = 1000,
value = 500,
width = "50%"
)
),
div( class = "col-xs-6",
plotOutput("distPlot", width = "100%")
)
)
)
server <- function(input, output) {
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
shinyApp(ui, server)
```
还要注意,图和滑块的宽度是相对于那一列的。