คุณสมบัติที่มาพื้นหลัง CSS
ตัวอย่าง
ให้ภาพพื้นหลังเริ่มจากมุมซ้ายบนของเนื้อหา:
#example1 {
border: 10px dashed black;
padding:
25px;
background: url(paper.gif);
background-repeat: no-repeat;
background-origin:
content-box;
}
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติbackground-origin
ระบุตำแหน่งต้นทาง (พื้นที่วางตำแหน่งพื้นหลัง) ของภาพพื้นหลัง
หมายเหตุ:คุณสมบัตินี้ไม่มีผลหาก การแนบพื้นหลัง "คงที่"
ค่าเริ่มต้น: | padding-box |
---|---|
รับการถ่ายทอด: | ไม่ |
เคลื่อนไหวได้: | ไม่. อ่านเกี่ยวกับแอนิเมชั่น |
รุ่น: | CSS3 |
ไวยากรณ์ JavaScript: | วัตถุ .style.backgroundOrigin="content-box" |
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
background-origin | 4.0 | 9.0 | 4.0 | 3.0 | 10.5 |
ไวยากรณ์ CSS
background-origin: padding-box|border-box|content-box|initial|inherit;
มูลค่าทรัพย์สิน
Value | Description | Play it |
---|---|---|
padding-box | Default value. The background image starts from the upper left corner of the padding edge | |
border-box | The background image starts from the upper left corner of the border | |
content-box | The background image starts from the upper left corner of the content | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
ตั้งค่าภาพพื้นหลังสองรูปสำหรับองค์ประกอบ <div> ให้ภาพพื้นหลัง "paper.gif" เริ่มจากมุมซ้ายบนของขอบช่องว่างภายใน และให้ภาพพื้นหลัง "img_tree.gif" เริ่มจากมุมซ้ายบนของเนื้อหา:
#example1 {
border: 10px dashed black;
padding: 25px;
background: url(img_tree.gif), url(paper.gif);
background-repeat: no-repeat;
background-origin:
content-box, padding-box;
}
หน้าที่เกี่ยวข้อง
กวดวิชาCSS: พื้นหลัง CSS
การอ้างอิง HTML DOM: คุณสมบัติ backgroundOrigin