CSS พื้นหลังชวเลข
พื้นหลัง CSS - คุณสมบัติชวเลข
ในการย่อโค้ด คุณยังสามารถระบุคุณสมบัติพื้นหลังทั้งหมดในคุณสมบัติเดียวได้ สิ่งนี้เรียกว่าคุณสมบัติชวเลข
แทนที่จะเขียนว่า
body {
background-color: #ffffff;
background-image:
url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
คุณสามารถใช้คุณสมบัติชวเลขbackground
:
ตัวอย่าง
ใช้คุณสมบัติชวเลขเพื่อตั้งค่าคุณสมบัติพื้นหลังในหนึ่งประกาศ:
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
เมื่อใช้คุณสมบัติชวเลข ลำดับของค่าคุณสมบัติคือ:
background-color
background-image
background-repeat
background-attachment
background-position
ไม่สำคัญว่าค่าคุณสมบัติตัวใดตัวหนึ่งจะหายไป ตราบใดที่ค่าอื่นๆ อยู่ในลำดับนี้ โปรดทราบว่าเราไม่ได้ใช้คุณสมบัติ background-attachment ในตัวอย่างด้านบน เนื่องจากไม่มีค่า
คุณสมบัติพื้นหลัง CSS ทั้งหมด
Property | Description |
---|---|
background | Sets all the background properties in one declaration |
background-attachment | Sets whether a background image is fixed or scrolls with the rest of the page |
background-clip | Specifies the painting area of the background |
background-color | Sets the background color of an element |
background-image | Sets the background image for an element |
background-origin | Specifies where the background image(s) is/are positioned |
background-position | Sets the starting position of a background image |
background-repeat | Sets how a background image will be repeated |
background-size | Specifies the size of the background image(s) |