I'm building a Shiny app, and I need to add some space (lets say ~5px) between columns in my 5-column layout. However, when I add left/right margins, the last column moves to the bottom of the previous one. My columns are required to:
- Have a separation of ~5px between them, as shown in Image3.
- Have roughly the same width (the layout resulting from my code is fine in that sense).
- Central column needs to have a solid background.
- The other ones need white background and a colored solid border.
I have read the documentation about css padding, margins and borders, and whether they increase the width of objects. I tried using box-sizing: border-box with no luck. I've also found some similar questions in SO but they are not Shiny related, and—as it can be deducted from my code—I'm not very experienced with CSS. Since my app is almost finished, I'd prefer an answer that uses in-line CSS.
library(shiny)
box_content <- p("color bordered", br(), "box")
central_box <- p("white bordered", br(), "central box")
st_box <- "margin: 0px 5px; border-radius: 25px; padding: 12px; box-sizing: border-box; border: 2px solid #F7941E; height: 169px; background-color: #ffffff; color: #444444;"
st_cent <- "margin: 0px 5px; border-radius: 25px; padding: 12px; box-sizing: border-box; border: 2px solid #ffffff; height: 169px; background-color: #79BDE8; color: #ffffff;"
ui <- fluidPage(
fluidRow( # boxes row
height = "185px",
column(5, # boxes 1-2
fluidRow(
height = "185px",
column(6, # box1
style = st_box,
box_content),
column(6, # box2
style = st_box,
box_content))),
column(7, # boxes 3-5
fluidRow(
height = "185px",
column(4, # central_box
style = st_cent,
central_box ),
column(4, # box3
style = st_box,
box_content ),
column(4, # box4
style = st_box,
box_content)))))
server <- function(input, output) { }
shinyApp(ui = ui, server = server)
Image1: Layout with no margins - notice central box has actually a white border
Image2: Layout with 5px margin - this is the image resulting from running the code shown