當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


HTML Style borderLeftStyle用法及代碼示例


HTML DOM中的Style borderLeftStyle屬性用於設置或返回元素的左邊框樣式。

用法:

  • 它返回borderLeftStyle屬性。
    object.style.borderTopStyle
  • 它用於設置borderLeftStyle屬性。
    object.style.borderLeftStyle = "none|hidden|dotted|dashed|solid|
    double|groove|ridge|inset|outset|initial|inherit"

屬性值:


影響
none 沒有創建邊框。它是默認值。
hidden 它與“ none”屬性相同,不同之處在於它在解決表元素中的邊界衝突時有所幫助。
dotted 點用作邊界。
dashed 虛線用作邊框。
solid 一條實線用作邊框。
double 兩行用作邊框。
groove 顯示3D帶凹槽的邊框。效果取決於border-color值。
ridge 顯示3D脊狀邊框。效果取決於border-color值。
inset 顯示3D插入邊框。效果取決於border-color值。
outset 顯示3D起始邊框。效果取決於border-color值。
initial 它將屬性設置為其初始值。
inherit 它將屬性設置為從其父級繼承。

範例1:本示例不介紹任何屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'none'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
none-before
單擊按鈕後:
none-after

範例2:本示例描述隱藏的屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
      
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'hidden'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
hidden-before
單擊按鈕後:
hidden-after

範例3:本示例描述了點分屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
      
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'dotted'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
dotted-before
單擊按鈕後:
dotted-after

範例4:本示例描述了虛線的屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'dashed'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
dashed-before
單擊按鈕後:
dashed-after

範例5:本示例描述了實體屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px dotted green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'solid'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
solid-before
單擊按鈕後:
solid-after


範例6:本示例描述了double屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'double'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
double-before
單擊按鈕後:
double-after

範例7:本示例描述凹槽屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'groove'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
groove-before
單擊按鈕後:
groove-after

範例8:本示例描述了脊屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
      
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'ridge'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
ridge-before
單擊按鈕後:
ridge-after

範例9:本示例描述插入屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
      
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'inset'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
inset-before
單擊按鈕後:
inset-after

範例10:本示例描述初始屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px inset green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'outset'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
outset-before
單擊按鈕後:
outset-after


示例11:本示例描述初始屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
      
    <b>DOM Style borderLeftStyle Property</b> 
      
    <p class="item"> 
        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="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'initial'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
initial-before
單擊按鈕後:
initial-after

示例12:本示例描述繼承屬性值。

<!DOCTYPE html> 
<html> 
      
<head> 
    <title> 
        DOM Style borderLeftStyle Property 
    </title> 
      
    <style> 
        #parent { 
            border-left-style:dotted; 
            padding:10px; 
        } 
  
        .item { 
            padding:10px; 
            border:15px solid green; 
        } 
    </style> 
</head> 
  
<body> 
    <h1 style="color:green">GeeksforGeeks</h1> 
    <b>DOM Style borderLeftStyle Property</b> 
      
    <div id="parent"> 
        <p class="item"> 
            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> 
      
    <button onclick="changeBorderStyle()"> 
        Change style 
    </button> 
  
    <script> 
        function changeBorderStyle() { 
            elem = document.querySelector('.item'); 
  
            // Setting the border style 
            elem.style.borderLeftStyle = 'inherit'; 
        } 
    </script> 
</body> 
  
</html>                    

輸出:
在單擊按鈕之前:
inherit-before
單擊按鈕後:
inherit-after

支持的瀏覽器:下麵列出了DOM Style borderLeftStyle屬性支持的瀏覽器:

  • 穀歌瀏覽器
  • IE瀏覽器
  • Firefox
  • 蘋果Safari
  • Opera


相關用法


注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 HTML | DOM Style borderLeftStyle Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。