Tuesday, June 4, 2024
 Popular · Latest · Hot · Upcoming
124
rated 0 times [  128] [ 4]  / answers: 1 / hits: 33696  / 11 Years ago, tue, february 4, 2014, 12:00:00

I would like to make a HTML input field readonly but without getting the grey background that appears when I just add the attribute readonly (it should look the same as a normal field just not allow editing).



Is there a way I can realise this in CSS and/or JS, ideally with a class ?



Example field:



<input type=text style=width:96% class=myClass />

More From » html

 Answers
5

Yes, you can use the :disabled pseudo class, e.g.



input.myClass:disabled {
/* style declaration here */
}

[#72738] Monday, February 3, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marcos

Total Points: 331
Total Questions: 106
Total Answers: 104

Location: Gabon
Member since Sat, Jul 25, 2020
4 Years ago
marcos questions
Thu, Feb 24, 22, 00:00, 2 Years ago
Sat, Apr 17, 21, 00:00, 3 Years ago
Mon, Feb 1, 21, 00:00, 3 Years ago
Tue, Jan 26, 21, 00:00, 3 Years ago
Wed, Jan 6, 21, 00:00, 3 Years ago
;