2016-12-06 7 views
0

テーブルのいくつかにパディングがないアプリを作ろうとしています。パディングなしの光沢のあるテーブル出力

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") 
    ) 
) 

上記のコードは、すべてのテーブルに空白がないようにしますが、2番目のテーブルには空白がないようにします。どうすれば解決できますか?

答えて

0

あなたは、独自のIDを使用して第二のテーブルを呼び出すことができます。

ui <- fluidPage(
    tags$head(
    tags$style(HTML(
     " 
     #smalltable table > thead > tr > th, 
     #smalltable table > tbody > tr > th, 
     #smalltable table > tfoot > tr > th, 
     #smalltable table > thead > tr > td, 
     #smalltable table > tbody > tr > td, 
     #smalltable table > tfoot > tr > td { 
     padding:0px; 

     }"))), 
    mainPanel(tableOutput("bigtable"), 
       tableOutput("smalltable") 
    ) 
    ) 
+0

感謝を!それはうまくいった! – Katom

関連する問題