CSS |左填充属性

原文:https://www.geeksforgeeks.org/css-padding-left-property/

填充是其内容和边框之间的空间。CSS 中的左填充属性用于设置元素左侧填充区域的宽度。

语法:

padding-left: length|percentage|initial|inherit;

属性值;

  • length: This mode is used to specify the size of padding as a fixed value. The default value is 0. It must be non-negative.

    语法:

    html padding-left: length;

    示例:

    ```html <!DOCTYPE html>     

                         padding-left Property                               .geek {                 padding-left: 90px;                 color: white;                 background: green;             }              

            

                GeeksforGeeks         

                padding-left Property         

            

                This paragraph has a padding-left: 90px;         

                              ```

    输出: paddingleft

  • percentage: This mode is used to specify the left padding in percent of the width of the element. It must be non-negative.

    语法:

    html padding-left: percentage;

    示例:

    ```html <!DOCTYPE html>     

                         padding-left Property                               .geek {                 padding-left: 25%;                 color: white;                 background: green;             }              

            

                GeeksforGeeks         

                padding-left Property         

            

                This paragraph has a padding-left: 25%;         

                              ```

    输出: paddingleft

  • 初始值:该属性用于将左填充设置为默认值。 语法:

    html padding-left: initial;

支持的浏览器:左填充属性支持的浏览器如下:

  • 谷歌 Chrome 1.0
  • Internet Explorer 4.0
  • Firefox 1.0
  • 歌剧 3.5
  • 苹果 Safari 1.0