我试图控制Shiny中的sliderInput的大小和外观.具体来说,我已经使它变得更大更宽,并且改变了滑块的背景颜色.我想使滑块的末端成为正方形,删除滑块下方出现的刻度线,然后将值(1:10)放在条形体内的白色中.我试图操纵CSS,但只取得了一定的成功.滑块更大更宽,但是条形的一侧是方形的,我无法移动文本.显然,我的CSS技能低于标准.我已经咨询了各种教程,但无法破解它们.非常感谢任何帮助,因为我真的被困住了.
这是我尝试过的:
ui <- fluidPage(
tags$style(HTML(".irs-bar {width: 100%; height: 25px; background: black; border-top: 1px solid black; border-bottom: 1px solid black;}")),
tags$style(HTML(".irs-bar-edge {background: black; border: 1px solid black; height: 25px; border-radius: 15px 15px 15px 15px;}")),
tags$style(HTML(".irs-line {border: 1px solid black; height: 25px;}")),
tags$style(HTML(".irs-grid-text {font-family: 'arial'; color: black}")),
tags$style(HTML(".irs-max {font-family: 'arial'; color: black;}")),
tags$style(HTML(".irs-min {font-family: 'arial'; color: black;}")),
tags$style(HTML(".irs-single {color:black; background:#6666ff;}")),
uiOutput("testSlider")
)
server <- function(input, output, session){
output$testSlider <- renderUI({
sliderInput(
inputId="test",
label=NULL,
min=1,
max=10,
value=5,
step = 1,
width='100%'
) # close slider input
}) # close renderUI
}
shinyApp(ui = ui, server=server)
Run Code Online (Sandbox Code Playgroud)
K. *_*hde 13
那个怎么样?
ui <- fluidPage(
tags$style(type = "text/css", "
.irs-bar {width: 100%; height: 25px; background: black; border-top: 1px solid black; border-bottom: 1px solid black;}
.irs-bar-edge {background: black; border: 1px solid black; height: 25px; border-radius: 0px; width: 20px;}
.irs-line {border: 1px solid black; height: 25px; border-radius: 0px;}
.irs-grid-text {font-family: 'arial'; color: white; bottom: 17px; z-index: 1;}
.irs-grid-pol {display: none;}
.irs-max {font-family: 'arial'; color: black;}
.irs-min {font-family: 'arial'; color: black;}
.irs-single {color:black; background:#6666ff;}
.irs-slider {width: 30px; height: 30px; top: 22px;}
"),
uiOutput("testSlider")
)
server <- function(input, output, session){
output$testSlider <- renderUI({
sliderInput(inputId="test", label=NULL, min=1, max=10, value=5, step = 1, width='100%')
})
}
shinyApp(ui = ui, server=server)
Run Code Online (Sandbox Code Playgroud)
irs.bar, .irs-bar-edge {border-radius: 0px}..irs-grid-pol {display: none;}..irs-grid-text {color: white; bottom: 17px; z-index: 1}其中z-index使得号码是一个层中的杆本身的上方..irs-slider {width: 30px; height: 30px; top: 22px;}了调整滑块旋钮.