Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
398 views
in Technique[技术] by (71.8m points)

html - 如何在没有id或class的输入字段中添加CSS?(How to add css to a input field without id or class?)

I need to add css to input field.

(我需要将CSS添加到输入字段。)

Using this npm package material-ui-search-bar in react app.

(在react app中使用这个npm package material-ui-search-bar 。)

<input type="text" autocomplete="off" spellcheck="false" id="undefined-Search-undefined-33442" value="sdfsfsfd" style="padding: 0px; position: relative; width: 100%; border: none; outline: none; background-color: rgba(0, 0, 0, 0); color: rgba(0, 0, 0, 0.87); cursor: inherit; font: inherit; opacity: 1; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); height: 100%;">

Tried these but it doesn't work :

(尝试了这些,但不起作用:)

input {
  color: white
}

and this, but its not working.

(这个,但它不起作用。)

input[type=text] {
  color: white;
}

I need the input text to be in white color.

(我需要输入文本为白色。)

  ask by vikas95prasad translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The npm site explains that you can add a style object as props to the compponent : material-ui-search-bar page in npm

(npm网站说明您可以将样式对象作为道具添加到npm中的compponent: material-ui-search-bar页面)

like this :

(像这样 :)

import SearchBar from 'material-ui-search-bar'

// ...
render() {
  return(
    <SearchBar
      style={{
        margin: '0 auto',
        maxWidth: 800 ,
        color: 'white'
      }}
    />
  )
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...