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

วิธีตั้งค่าว่าเส้นขอบภาพควรซ้ำ โค้ง หรือยืดด้วย JavaScript


ใช้คุณสมบัติ borderImageRepeat เพื่อตั้งค่าว่าเส้นขอบภาพจะถูกซ้ำ โค้ง หรือยืด

ตัวอย่าง

คุณสามารถลองรันโค้ดต่อไปนี้เพื่อเรียนรู้วิธีตั้งค่าให้เส้นขอบภาพถูกซ้ำ โค้ง หรือยืด −

<!DOCTYPE html> <html>    <head>       <style>          div{             background-color: blue;             border: 30px solid;             border-image: url('https://www.tutorialspoint.com/html5/images/html5-mini-logo.jpg');             border-image-slice: 10 10 30 30;             border-image-width: 1 1 1 1;             border-image-repeat: stretch;          }       </style>    </head>    <body>       <div id="box">          <p>             Demo Text!          </p>       </div>       <button onclick="display()">Click me!</button>       <script>          function display() {             document.getElementById("box").style.borderImageRepeat = "round";          }       </script>    </body> </html>