如何调整HTML表格的大小以适合计算机的屏幕?这是我闪亮的应用当前的外观,我尝试过使用流畅的行列,但效果不理想。我想我在这里想念什么。
这是我闪亮的服务器和用户界面
UI.R
library("shiny")
library(daff)
library(dplyr)
library(shinythemes)
setwd("PATH")
ui <- fluidPage(theme = shinytheme("cerulean"),
fluidPage(
titlePanel("Automated Data Dictionary Comparison"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = 'Dic1',
label = 'Choose First Data Dictionary:',
choices = list.files(path = "./data",
full.names = FALSE,
recursive = FALSE)),
selectInput(inputId = 'Dic2',
label = 'Choose Second Data Dictionary:',
choices = list.files(path = "./data",
full.names = FALSE,
recursive = FALSE))
),
mainPanel(
uiOutput('contents'))
)
)
)
HTML表在输出部分中。
SERVER.R
library(shiny)
library(dplyr)
library(daff)
library(shinythemes)
setwd("PATH")
server <- function(input, output) {
# Parse first file
dataset1 <- reactive({
infile <- input$Dic1
if (is.null(infile)){
return(NULL)
}
x <- read.csv(paste0("./data/", infile[[1]]))
x
})
# Parse second file
dataset2 <- reactive({
infile <- input$Dic2
if (is.null(infile)){
return(NULL)
}
x <- read.csv(paste0("./data/", infile[[1]]))
x
})
# Create comparison table (reactive as both of its elements are reactive)
diff <- reactive({
x <- render_diff(diff_data(data_ref=dataset1(), data=dataset2()),use.DataTables=TRUE)
x
})
#Output
output$contents <- renderUI({
HTML(diff())
})
}
预期结果是我的表可以在屏幕上完全看到,而无需扩展,我必须滚动才能在屏幕外看到整个表
答案 0 :(得分:0)
尝试使用
mainPanel(
HTML("<div style ='overflow:auto; ' >"),
uiOutput('contents'),
HTML("</div>")
)
或尝试设置height
或使用CSS设置width
mainPanel(
HTML("<div style ='overflow:auto; height:500px ' >"),
uiOutput('contents'),
HTML("</div>")
)