Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

HTML DOM สไตล์ borderImageRepeat คุณสมบัติ


คุณสมบัติ HTML DOM borderImageRepeat ใช้เพื่อกำหนดวิธีที่แบ่งส่วนของรูปภาพซ้ำในรูปภาพเส้นขอบ ค่านี้กำหนดหรือได้รับหาก borderImage ควรถูกปัดเศษ ทำซ้ำหรือยืดออก

ไวยากรณ์

ต่อไปนี้เป็นไวยากรณ์สำหรับ −

การตั้งค่าคุณสมบัติ borderImageRepeat

object.style.borderImageRepeat = "stretch|repeat|round|initial|inherit"

คุณค่า

ค่าคุณสมบัติอธิบายได้ดังนี้ -

ซีเนียร์ คุณค่าและคำอธิบาย
1 ยืดกล้ามเนื้อ
ทำให้ภาพยืดออกจนเต็มพื้นที่ นี่คือค่าเริ่มต้น
2 ซ้ำ
ทำให้ภาพซ้ำเติมพื้นที่
3 รอบ
รูปภาพมักจะถูกทำซ้ำเพื่อเติมเต็มพื้นที่และจะถูกปรับขนาดใหม่หากไม่เติมเต็มพื้นที่ด้วยจำนวนครั้งทั้งหมด
4 ช่องว่าง
เช่นเดียวกับวงกลม แต่ถ้ารูปภาพไม่ซ้ำกันจำนวนเต็ม พื้นที่รอบ ๆ ไทล์จะถูกกระจาย
5 เริ่มต้น
สำหรับการตั้งค่าคุณสมบัตินี้เป็นค่าเริ่มต้น
6 สืบทอด
เพื่อสืบทอดค่าคุณสมบัติหลัก

ตัวอย่าง

ให้เราดูตัวอย่างคุณสมบัติ borderImageRepeat -

<!DOCTYPE html>
<html>
<head>
<style>
   #b1 {
      border: 30px solid transparent;
      padding: 5px;
      border-image-source:
      url("https://www.tutorialspoint.com/data_structures_algorithms/images/data-structurealgorithm.jpg");
      border-image-repeat: repeat;
      border-image-slice: 30;
   }
</style>
<script>
   function changeBorderRepeat(){
      document.getElementById("b1").style.borderImageRepeat="stretch";
      document.getElementById("Sample").innerHTML="The border image will now be
      stretched";
   }
</script>
</head>
<body>
<h2>Demo Heading</h2>
<p id="b1">This is some random text inside the paragraph. Here is another line in this paragraph</p>
<p>Change the above div border image repeat property by clicking the below button</p>
<button onclick="changeBorderRepeat()">Change Border Repeat</button>
<p id="Sample"></p>
</body>
</html>

ผลลัพธ์

สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

HTML DOM สไตล์ borderImageRepeat คุณสมบัติ

เมื่อคลิกปุ่มยุบเส้นขอบ -

HTML DOM สไตล์ borderImageRepeat คุณสมบัติ