【问题标题】:Overriding CSS in Shiny progress bar在闪亮的进度条中覆盖 CSS
【发布时间】:2018-05-29 06:14:08
【问题描述】:

我试图了解为什么我的进度条(使用 timer.js 创建)中有灰色背景。

我尝试将背景颜色、背景样式更改为无或#FFFFFF,但灰色背景仍然存在。

服务器.R

function(input, output, session) {
  mylevels <- reactive({
    Sys.sleep(100)
    input$num_levels
  })
  output$out <- renderText({
      return(paste0(mylevels()," is selected.."))
  })
}

ui.R:

library("shinythemes")
fluidPage(theme = shinytheme("spacelab"),

navbarPage("Test", id = "allResults",           
    tabPanel(value ='inputParam', title = 'User Actions',
        sidebarLayout(
          sidebarPanel(
            # Show Timer
            conditionalPanel("updateBusy() || $('html').hasClass('shiny-busy')",
                id='progressIndicator',
                "Calculation in progress ....\n",
                div(class='progress',includeHTML("timer.js"))
            ),

            tags$head(tags$style(type="text/css",
                '#progressIndicator {',
                '  position: fixed; bottom: 15px; right: 15px; width: 225px; height: 70px;',
                '  padding: 8px; border: 0.5px dotted #CCC; border-radius: 8px; ',
                '}'
            )),

            numericInput("num_levels", label = "", value = 3)
          ),
          mainPanel(
            textOutput('out')
          )
        )
    )
))

<script type="text/javascript">
var wasBusy = false;
var elapsedTimer = null;
var startTime = null;
function updateBusy() {
  var isBusy = $('html').hasClass('shiny-busy');
  if (isBusy && !wasBusy) {
    startTime = new Date().getTime();
    elapsedTimer = setInterval(function() {
      var millisElapsed = new Date().getTime() - startTime;
      $('.progress').text(Math.round(millisElapsed/1000) + ' seconds have elapsed');
    }, 1000);
  }
  else if (!isBusy && wasBusy) {
    clearInterval(elapsedTimer);
  }
  wasBusy = isBusy;
}
</script>

【问题讨论】:

  • 一个工作的 jsfiddle 或 codepen 可以提供帮助。您包含的此代码由于缺少库等而有错误
  • 我认为缺少的部分是 timer.js(这是最底部的 sn-p)
  • 您在样式属性的末尾使用了!important
  • 我不明白。 !important 是什么意思?
  • background-color: #FFFFFF !important。如果我能看到现场经验可以帮助你更多

标签: javascript css r shiny shinythemes


【解决方案1】:

将以下内容添加到ui.r 中的text/css 样式标签:

.progress {background:#FFFFFF; box-shadow:none;}

【讨论】:

    猜你喜欢
    • 2019-01-20
    • 1970-01-01
    • 2017-11-08
    • 1970-01-01
    • 2021-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-23
    相关资源
    最近更新 更多