【发布时间】:2016-12-07 17:09:08
【问题描述】:
我正在尝试制作一些表格没有填充的应用程序。
server <- function(input, output) {
url = c("http://lorempixel.com/output/animals-q-c-480-480-7.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-1.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-8.jpg",
"http://lorempixel.com/output/animals-q-c-480-480-6.jpg"
)
image <- paste0( '<img src="',url,'" width=WIDTH></img>')
big.image <- gsub("WIDTH", "200px", image)
small.image <- gsub("WIDTH", "100px", image)
big.df <- data.frame(col1 = c(big.image[1], "Lorem", big.image[2], "Ipsum"),
col2 = c(big.image[3], "Dolor", big.image[4], "Sit"))
small.df <- data.frame(col1 = c(small.image[1], "Lorem", small.image[2], "Ipsum"),
col2 = c(small.image[3], "Dolor", small.image[4], "Sit"))
output$bigtable <- renderTable(big.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
output$smalltable <- renderTable(small.df,
sanitize.text.function = function(x) x,
align='c',
colnames=F
)
}
ui <- fluidPage(
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
上面的代码创建了一个包含大图像表格和小图像表格的应用。我希望大图像表保持其当前间距,而小图像表没有间距。
ui <- fluidPage(
tags$head(
tags$style(HTML(
"
.table.shiny-table > thead > tr > th,
.table.shiny-table > tbody > tr > th,
.table.shiny-table > tfoot > tr > th,
.table.shiny-table > thead > tr > td,
.table.shiny-table > tbody > tr > td,
.table.shiny-table > tfoot > tr > td {
padding:0px;
}"))),
mainPanel(tableOutput("bigtable"),
tableOutput("smalltable")
)
)
上面的代码会让所有的表格都没有间距,但我只希望第二个没有间距。我该如何解决这个问题?
【问题讨论】:
标签: css r shiny html-table padding