简体   繁体   English

更改textInput闪亮小部件的占位符颜色

[英]Change placeholder color of textInput shiny widget

with some CSS code found in different old posts on Stackoverflow I managed to change the placeholder colour of every selectizeInput and selectInput widget of my shinyapp, but it seems that this code doesn't work for the textInput widgets. 使用在Stackoverflow上的不同旧帖子中找到的一些CSS代码,我设法更改了我的shinyapp的每个selectizeInput和selectInput小部件的占位符颜色,但似乎此代码不适用于textInput小部件。

Below you can find a basic reproducible example: 您可以在下面找到一个基本可重复的示例:


library(shiny)

ui <- fluidPage(

  tags$style(HTML("::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
                   color: red;
                   opacity: 1; /* Firefox */}

                  :-ms-input-placeholder { /* Internet Explorer 10-11 */
                  color: red;}

                  ::-ms-input-placeholder { /* Microsoft Edge */
                  color: red;
                  }")),

br(),

  selectizeInput(inputId = "one",
                 label = NULL,
                 choices = c("Letters" = "", "A", "B", "C"),
                 selected = ""),

br(),

  textInput(inputId = "two",
            label = NULL,
            placeholder = "Numbers",
            value = "")

)

server <- function(input, output, session) {

}

shinyApp(ui, server)

As you can see, the placeholder of the textInput widget remains gray, while I would like it to be red as well. 如您所见,textInput小部件的占位符保持灰色,而我希望它也是红色的。

Thank you in advance for your help! 预先感谢您的帮助!

It seems plausible that your problem lies purely in adding your CSS, since doing 似乎有理由认为你的问题完全在于添加你的CSS,因为这样做

var q = document.createElement("style");
q.innerHTML = `::placeholder { color: red }`;
document.body.appendChild(q)

on the selectize demo page does indeed color the placeholder text red. selectize演示页面上确实将占位符文本的颜色设置为红色。

As for the second question, for targeting a specific element you want your selector to be like 至于第二个问题,要定位特定元素,您希望选择器就像

#e6-selectized::placeholder { color: red }

(note the suffix) (注意后缀)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM