สไตล์พื้นหลังคุณสมบัติซ้ำ
ตัวอย่าง
ตั้งค่า background-image เป็น no-repeat:
document.body.style.backgroundRepeat = "repeat-y";
ตัวอย่าง "ลองใช้เอง" เพิ่มเติมด้านล่าง
ความหมายและการใช้งาน
คุณสมบัติ backgroundRepeat ตั้งค่าหรือส่งคืนวิธีการทำซ้ำ (ไทล์) ภาพพื้นหลัง
รองรับเบราว์เซอร์
ตัวเลขในตารางระบุเบราว์เซอร์รุ่นแรกที่สนับสนุนคุณสมบัติอย่างสมบูรณ์
Property | |||||
---|---|---|---|---|---|
backgroundRepeat | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
ไวยากรณ์
ส่งคืนคุณสมบัติ backgroundRepeat:
object.style.backgroundRepeat
ตั้งค่าคุณสมบัติ backgroundRepeat:
object.style.backgroundRepeat = "repeat|repeat-x|repeat-y|no-repeat|initial|inherit"
มูลค่าทรัพย์สิน
Value | Description |
---|---|
repeat | The background image is repeated both vertically and horizontally. This is default |
repeat-x | The background image is only repeated horizontally |
repeat-y | The background image is only repeated vertically |
no-repeat | The background-image is not repeated |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
รายละเอียดทางเทคนิค
ค่าเริ่มต้น: | ทำซ้ำ |
---|---|
คืนมูลค่า: | สตริงที่แสดงถึงการทำซ้ำภาพพื้นหลัง |
เวอร์ชัน CSS | CSS1 |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
เปลี่ยนคุณสมบัติ backgroundRepeat ขององค์ประกอบ DIV ที่ระบุ:
document.getElementById("myDIV").style.backgroundRepeat = "repeat-x";
ตัวอย่าง
ตั้งค่าภาพพื้นหลังให้ทำซ้ำในแนวนอนหรือแนวตั้ง:
function repeatVer()
{
document.body.style.backgroundRepeat = "repeat-y";
}
function repeatHor() {
document.body.style.backgroundRepeat = "repeat-x";
}
ตัวอย่าง
ส่งกลับค่าพื้นหลังซ้ำของเอกสาร:
alert(document.body.style.backgroundRepeat);
หน้าที่เกี่ยวข้อง
กวดวิชาCSS: พื้นหลัง CSS
การอ้างอิง CSS: คุณสมบัติตำแหน่งพื้นหลัง
การอ้างอิง CSS: คุณสมบัติการทำซ้ำพื้นหลัง
การอ้างอิง HTML DOM: คุณสมบัติพื้นหลัง