Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> CSS

Vai trò bộ chọn :read-only trong CSS

Bộ chọn :read-only - Lặp lại

Nội dung trùng lặp với bài 1003062664. :read-only chọn phần tử không thể sửa.

Ví dụ (giống hệt bài trước)

<!DOCTYPE html>
<html>
<head>
  <style>
    input:read-only {
      background-color: blue;
      color: white;
    }
  </style>
</head>
<body>
  <form>
    Môn học: <input type="text" name="subject" value="Toán"><br>
    Sinh viên: <input type="text" name="student" readonly value="Amit"><br>
  </form>
</body>
</html>

Input "Sinh viên" (readonly) → nền xanh.