:not(:empty):在伪类/元素组合之前

时间:2017-07-10 15:14:01

标签: css pseudo-element pseudo-class

我想仅在内容存在的情况下才显示标签。

这不起作用: https://jsfiddle.net/9g0amsh1/

## ui.R
shinyUI(fluidPage(
  sliderInput(
    "rows_to_show",
    "Exponent",
    min = 10,
    max = 50,
    value = 5
  ),
  dataTableOutput("table")
))


## server.R
library("shiny")
library("tidyverse")
library("dbplyr")
library("pool")
library("RMySQL")
## tryCatch so the app will actually run
tryCatch(
  the_db <- dbPool(
    drv = RMySQL::MySQL(),
    dbname = "the_db",
    port = 3306,
    host = "163.1.169.xxx",
    user = "database_username" 
  ),
  error = function(e)
    e
)

shinyServer(function(input, output, session) {
  database_username <- eventReactive(input$exponent,
                                     {
                                       if (session$clientData$url_hostname == "127.0.0.1") {
                                         "local_username"
                                       } else {
                                         "remote_username"
                                       }
                                     }, ignoreInit = FALSE)


  output$table <- renderDataTable({
    rows_to_show <- as.numeric(input$rows_to_show)

    # the_db %>%
    #   tbl("my_table") %>%
    #   collect() %>%
    #   slice(1:rows_to_show)
    iris %>%
      slice(1:rows_to_show)

  })

})
.views-field-field-documents .field-content:not(:empty):before {
  content: "Documents associés : ";
  float: left;
}

1 个答案:

答案 0 :(得分:1)

indeed whitespace counts.

https://jsfiddle.net/e2mLh9tz/

<div class="views-field views-field-field-documents"><div class="field-content"></div></div>

<div class="views-field views-field-field-documents"><div class="field-content"><span class="file file--mime-application-pdf file--application-pdf"><a href="http://dud-dev.univ-amu.fr/system/files/article/documents/boarding-pass.pdf" type="application/pdf; length=117264">boarding-pass.pdf</a></span>
</div></div>