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

Tạo kiểu cho input disabled với CSS

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

Nội dung trùng lặp với bài 1003062623. Sử dụng :disabled để tạo kiểu cho input có thuộc tính disabled.

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

<!DOCTYPE html>
<html>
<head>
  <style>
    input:enabled  { background: blue; }
    input:disabled { background: red; }
  </style>
</head>
<body>
  <form action="">
    Môn học: <input type="text" name="subject"><br>
    Sinh viên: <input type="text" name="student"><br>
    Tuổi: <input type="number" name="age" disabled><br>
  </form>
</body>
</html>

Input "Tuổi" bị disabled → nền đỏ. Các input còn lại → nền xanh.