行的高度是响应式的,由列元素的高度决定。例如,我们在第一行使用两个元素,高度分别为 200 和 100 像素。该行采用其元素的最大高度。第二行包含高度分别为 100 和 150 像素的元素,并再次采用最大元素的高度。
library(shiny)
runApp(list(
ui = fluidPage(
fluidRow(
column(6,div(style = "height:200px;background-color: yellow;", "Topleft")),
column(6,div(style = "height:100px;background-color: blue;", "Topright"))),
fluidRow(
column(6,div(style = "height:100px;background-color: green;", "Bottomleft")),
column(6,div(style = "height:150px;background-color: red;", "Bottomright")))
),
server = function(input, output) {
}
))
为了更好地控制诸如 bootstrap 之类的库,您可以使用 CSS 设置元素的样式,例如,我们可以为每一行添加一个类并根据需要设置其高度和其他属性:
library(shiny)
runApp(list(
ui = fluidPage(
fluidRow(class = "myRow1",
column(6,div(style = "height:200px;background-color: yellow;", "Topleft")),
column(6,div(style = "height:100px;background-color: blue;", "Topright"))),
fluidRow(class = "myRow2",
column(6,div(style = "height:100px;background-color: green;", "Bottomleft")),
column(6,div(style = "height:150px;background-color: red;", "Bottomright")))
, tags$head(tags$style("
.myRow1{height:250px;}
.myRow2{height:350px;background-color: pink;}"
)
)
),
server = function(input, output) {
}
))
我们在这里向 head 元素传递了一个样式标签来规定我们的样式。有多种方式可以实现样式,请参阅http://shiny.rstudio.com/articles/css.html