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

คุณสมบัติ background แบบ shorthand สำหรับกำหนดพื้นหลังใน CSS


Shorthand Property: background

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

ตัวอย่าง

<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: #f0f0f0 url(bg.png) center/cover no-repeat fixed padding-box border-box;

คุณสมบัติที่ละเว้นจะใช้ค่าเริ่มต้น