当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。