Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

จัดสไตล์อินพุตที่มี readonly ด้วย CSS


Pseudo-class :read-only

ใช้ :read-only เลือก <input> ที่มีแอตทริบิวต์ readonly

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    input:read-only {
      background-color: blue;
      color: white;
    }
  </style>
</head>
<body>
  <form>
    Subject: <input type="text" name="subject" value="Maths"><br>
    Student: <input type="text" name="student" readonly value="Amit"><br>
  </form>
</body>
</html>