CSS |描边线帽属性

原文:https://www.geeksforgeeks.org/css-stroke-linecap-property/

描边线帽属性用于定义在开放子路径末端使用的形状。

语法:

stroke-linecap: butt | round | square | initial | inherit

属性值:

  • butt: It is used to indicate that the stroke will not extend beyond the endpoints of the stroke. It makes the stroke appear to end at a sharp right angle.

    示例:

    ```html <!DOCTYPE html>

           CSS | stroke-linecap           / Assume the round        value for        demonstration /     .stroke-round {       stroke-linecap: round;

    stroke-width: 20px;       stroke: green;     }

    .stroke-butt {       stroke-linecap: butt;

    stroke-width: 20px;       stroke: red;     }      

        GeeksforGeeks   

           CSS | stroke-linecap      
                              
    ```

    输出:比较回合值和对接值 butt

  • round: It is used to indicate that the ends of the stroke are extended with a semicircle of the diameter equal to the stroke width. A zero length subpath would have a full circle that is centered at the subpath’s point.

    示例:

    ```html <!DOCTYPE html>

           CSS | stroke-linecap           / This is the        default value /     .stroke-butt {       stroke-linecap: butt;

    stroke-width: 20px;       stroke: green;     }

    .stroke-round {       stroke-linecap: round;

    stroke-width: 20px;       stroke: red;     }      

        GeeksforGeeks   

           CSS | stroke-linecap      
                              
    ```

    输出:将对接值与圆值 进行比较round

  • square: It is used to indicate that the ends of the stroke is extended with a rectangle whose height is equal to the width of the stroke and the width is equal to half the width of the stroke. A zero-length subpath would have a square that is centered at the subpath’s point.

    示例:

    ```html <!DOCTYPE html>

           CSS | stroke-linecap           / This is the default        value /     .stroke-butt {       stroke-linecap: butt;

    stroke-width: 20px;       stroke: green;     }

    .stroke-square {       stroke-linecap: square;

    stroke-width: 20px;       stroke: red;     }      

        GeeksforGeeks   

           CSS | stroke-linecap      
                              
    ```

    输出:比较对接值和平方值 square

  • initial: It is used to set the property to its default value.

    示例:

    ```html <!DOCTYPE html>

           CSS | stroke-linecap           / Assume the round        value for        demonstration /     .stroke-round {       stroke-linecap: round;

    stroke-width: 20px;       stroke: green;     }

    .stroke-butt {       stroke-linecap: butt;

    stroke-width: 20px;       stroke: red;     }   

      

        GeeksforGeeks   

           CSS | stroke-linecap      
                              
    ```

    输出:比较舍入值和初始值 initial

  • 继承:用于设置属性从其父级继承。

支持的浏览器:笔画线帽属性支持的浏览器如下:

  • 火狐浏览器
  • 旅行队
  • 歌剧
  • Internet Explorer 9