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

การใช้งานคุณสมบัติ background แบบ shorthand ใน CSS


คุณสมบัติ background (Shorthand)

คุณสมบัติ background ใช้เป็น shorthand เพื่อกำหนดคุณสมบัติพื้นหลังหลายอย่างพร้อมกัน เช่น ภาพ ตำแหน่ง การซ้ำ เป็นต้น

ตัวอย่าง

<html>
  <head>
  </head>
  <body>
    <p style="background:url(/images/pattern1.gif) repeat fixed;">
      This paragraph has fixed repeated background image. </p>
  </body>
</html>

ลำดับค่าที่แนะนำ:

background: <color> <image> <position> <size> <repeat> <attachment> <origin> <clip>;

ตัวอย่าง: background: #fff url(bg.jpg) center/cover no-repeat fixed;

คุณสมบัติที่ข้ามไปจะใช้ค่าเริ่มต้นอัตโนมัติ