How to style readonly attribute with CSS?

后端 未结 9 1689
忘了有多久
忘了有多久 2020-12-12 21:45

I\'m currently using readonly=\"readonly\" to disable fields. I\'m now trying to style the attribute using CSS. I\'ve tried using

input[readonly] {
/*styling         


        
9条回答
  •  孤街浪徒
    2020-12-12 22:04

    If you select the input by the id and then add the input[readonly="readonly"] tag in the css, something like:

     #inputID input[readonly="readonly"] {
         background-color: #000000;
     }
    

    That will not work. You have to select a parent class or id an then the input. Something like:

     .parentClass, #parentID input[readonly="readonly"] {
         background-color: #000000;
     }
    

    My 2 cents while waiting for new tickets at work :D

提交回复
热议问题