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

เพิ่มสีพื้นหลังให้กับอินพุตแบบฟอร์มด้วย CSS


หากต้องการเพิ่มสีพื้นหลังให้กับอินพุตของแบบฟอร์ม ให้ใช้ background-color ทรัพย์สิน

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้คุณสมบัติสีพื้นหลังในรูปแบบ

ตัวอย่าง

<!DOCTYPE html>
<html>
   <head>
      <style>
         input[type=text] {
            width: 100%;
            padding: 10px 15px;
            margin: 5px 0;
            box-sizing: border-box;
            background-color: gray;
         }
      </style>
   </head>
   <body>
      <p>Fill the below form,</p>
      <form>
         <label for = "subject">Subject</label>
         <input type = "text" id = "subject" name = "sub">
         <label for = "student">Student</label>
         <input type = "text" id = "student" name = "stu">
      </form>
   </body>
</html>