DOM樣式的borderTopRightRadius屬性用於設置或返回元素右上邊界的半徑。
用法:
- 獲取borderTopRightRadius屬性
object.style.borderTopRightRadius
- 設置borderTopRightRadius屬性
object.style.borderTopRightRadius = "length | percentage | initial | inherit"
屬性值:
- length:用於定義固定長度單位的半徑。可以使用兩個值來指定四分之一橢圓的半徑,第一個值是水平半徑,第二個值是垂直半徑。
示例1:使用一個值指定半徑。
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> .elem { padding:10px; border-style:solid; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = '30px'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
示例2:使用兩個值指定半徑。
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> .elem { padding:10px; border-style:solid; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = '10px 30px'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
- percentage:這用於以百分比為單位定義半徑。可以使用兩個值來指定四分之一橢圓的半徑,第一個值是水平半徑,它是邊框的寬度的百分比,第二個值是垂直半徑,是border-box的高度的百分比。
示例3:使用一個值指定半徑。
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> .elem { padding:10px; border-style:solid; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = '20%'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
示例4:使用兩個值指定半徑。
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> .elem { padding:10px; border-style:solid; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p>> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = '10% 50%'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
- initial:這用於將此屬性設置為其默認值。
示例5:
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> .elem { padding:10px; border-style:solid; border-top-right-radius:20px; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = 'initial'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
- inherit:這將從其父項繼承該屬性。
示例6:
<!DOCTYPE html> <html lang="en"> <head> <title> DOM Style BorderTopRightRadius </title> <style> #parent { padding:10px; border-style:solid; /* Setting the borderTopRightRadius of the parent */ border-top-right-radius:30px; } .elem { padding:10px; border-style:solid; } </style> </head> <body> <h1 style="color:green"> GeeksforGeeks </h1> <b> DOM Style BorderTopRightRadius </b> <br> <br> <div id="parent"> <p class="elem"> GeeksforGeeks is a computer science portal with a huge variety of well written and explained computer science and programming articles, quizzes and interview questions. </p> </div> <br> <button onclick="changeRadius()"> Change borderTopRightRadius </button> <!-- Script to change borderTopRightRadius --> <script> function changeRadius() { elem = document.querySelector('.elem'); elem.style.borderTopRightRadius = 'inherit'; } </script> </body> </html>
輸出:
在單擊按鈕之前:
單擊按鈕後:
支持的瀏覽器:borderTopRightRadius屬性支持的瀏覽器如下:
- 穀歌瀏覽器
- Internet Explorer 9.0
- Firefox
- 蘋果Safari
- Opera
相關用法
- HTML Style right用法及代碼示例
- HTML Style top用法及代碼示例
- HTML Style textAlign用法及代碼示例
- HTML Style borderRight用法及代碼示例
- HTML Style borderLeft用法及代碼示例
- HTML Style wordSpacing用法及代碼示例
- HTML Style whiteSpace用法及代碼示例
- HTML Style height用法及代碼示例
- HTML Style textDecorationLine用法及代碼示例
- HTML Style columnRuleStyle用法及代碼示例
- HTML Style display用法及代碼示例
- HTML Style transformStyle用法及代碼示例
- HTML Style visibility用法及代碼示例
- HTML Style animationDirection用法及代碼示例
- HTML Style columnFill用法及代碼示例
注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 HTML | DOM Style borderTopRightRadius Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。