CSS有条不紊地使用祖先节点的百分比?

时间:2016-04-01 07:49:24

标签: css css3 css-float

当模块嵌套在HTML中时,我正在寻找响应式设计的一般最佳实践。是否有displayposition等标准属性允许将width/height/left/top/right/bottom属性传递给子级? float/clear曾用于为儿童提供新的石板吗?

在我的示例中,这意味着在#main标记内为<img><a>使用string = 'happy' print(string) 祖先的百分比宽度。现在,我的百分比似乎是基于兄弟文本宽度和相应的CSS表格单元格宽度。

enter image description here

谢谢

1 个答案:

答案 0 :(得分:0)

  

是否有标准属性,如显示和位置,允许将宽度/高度/左/上/右/下属性传递给儿童?

您不能将父级属性传递给子级,但您确定可以从父级inherit传递,例如在children元素中使用position:inherit,您可以继承父对位置的任何值。

现在,对于宽度和高度,您必须使用百分比。在您的情况下,您在锚标记上使用display:inline-block,其行为几乎与使用display:block float:left;时使用#main-work .section{ display:inline-block; width: calc(100%/3); } 但我没有看到您使用任何宽度属性。

试试这个:

library(shiny)
library(DT)
library(ggplot2)

x <- as.numeric(1:1000000)
y <- as.numeric(1:1000000)
z <- as.numeric(1:1000000)
data <- data.frame(x,y, z)

shinyApp(
  ui = fluidPage(selectInput(inputId = "yaxis", 
                             label = "Y-axis",
                             choices = list("x","y","z"), 
                             selected = c("x")),
  dataTableOutput('tableId'),
                 plotOutput('plot1')),
  server = function(input, output) {    
    output$tableId = renderDataTable({
      datatable(data, options = list(pageLength = 10, lengthMenu=c(10,20,30)))
    })
    output$plot1 = renderPlot({
      filtered_data <- data[input$tableId_rows_all, ]
      ggplot(data=filtered_data, aes_string(x="x",y=input$yaxis)) + geom_line()  
    })
  }
)  
相关问题