简体   繁体   中英

CSS: readonly property of textarea affects/changes background color

I applied a readonly property to textarea as shown

<textarea readonly>text area content</textarea>

This is the textarea css code

textarea{
  font-size: 15px;
  font-family: "Helvetica Neue";
  margin: 0 0 0.2rem 0;
  color: #000;
  width: auto;
  word-wrap: break-all;

    resize: none;
    overflow: hidden;
    min-height: 5px;
    height: 1px;
    max-height: inherit;
    background: #c3fdb8;
}

The is picture illustrating my present challenge 在此处输入图片说明 I want to retain the background color of the textarea assuming readonly property is applied.

Try adding

textarea,textarea[readonly] {

...

}

To the css. This'll make sure the browser's default readonly CSS is overruled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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