css - 在 Shiny R 中设置页列的高度
问题描述
我最近问了一个关于如何在此处将 Shiny App 页面的整个列变灰的问题。但是我发现页面列的高度是由内部对象的高度决定的,这意味着灰色调整到列的高度,并且不适用于它下面的空白区域,如果有的话。我的解决方案是确保所有列的高度填满整个页面,而不是根据内部对象的高度。但是如何调整列高?
这是一个MWE:
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
tags$head(tags$style(
'
.grey-out {
background-color: #eee;
opacity: 0.2;
}
'
)),
navbarPage(title = "Grey out",
tabPanel(title = "test",
column(width = 6, id ="left",
actionButton(inputId = "go", label = "GO"),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ....")
),
column(width = 6, id ="right",
actionButton(inputId = "back", label = "BACK"),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ...."),
p("some text ....")
),
tags$script(
'
$("#go").click(function(){
$("#left").addClass("grey-out");
$("#right").removeClass("grey-out");
});
$("#back").click(function(){
$("#right").addClass("grey-out");
$("#left").removeClass("grey-out");
});
'
)
)
)
)
server <- function (session, input, output) {
disable(id = "back")
observe({
req(input$go)
enable(id = "right")
disable(id = "left")
})
observe({
req(input$back)
enable(id = "left")
disable(id = "right")
})
}
shinyApp(ui = ui, server = server)
解决方案
您可以在列中使用 CSS height:100vh
:
column(width = 6, id ="left",
style = "height: 100vh;",
actionButton(inputId = "go", label = "GO"),
......
或者,更简单,把它放在类中:
.grey-out {
background-color: #eee;
opacity: 0.2;
height: 100vh;
}
推荐阅读
- python - 如何导入大型 csv 文件并执行操作
- reactjs - 如何修复 '_react["default"].memo 不是函数。(在 React native 的 '_react["default"].memo(connectFunction)' 错误中?
- python - 如何修复在lora中创建应用程序
- angular - Angular 7 cli不读取自定义ts文件
- ansible - 使用“azure_rm_deployment”时,资源组是在“我们西部”的特定位置创建的吗?
- php - 如何缩短这部分代码?
- php - 使用 eloquent 获取表模式,获取数组到字符串的转换错误
- angular - 如何在 Angular mono repo 中使用独立库?
- android - Android控制视图可见性,我得到错误
- vue.js - 通过迭代创建菜单时出现问题