语法
padding-top: length | initial | inherit;
padding-top 属性示例:
<!DOCTYPE html> <html> <head> <title>The 文档的标题</title> <style> p { border: 2px solid #666; color: #8ebf42; padding-top: 30px; } </style> </head> <body> <h2>Padding-top 属性示例</h2> <p>经历过风雨,才懂得阳光的温暖。</p> </body> </html>
在“em”中设置的 padding-top 属性示例。
<!DOCTYPE html> <html> <head> <title>The 文档的标题</title> <style> p { border: 2px solid #666; color: #8ebf42; padding-top: 4em; } </style> </head> <body> <h2>Padding-top 属性示例</h2> <p>经历过风雨,才懂得阳光的温暖。</p> </body> </html>
以百分比指定的 padding-top 属性示例:
<!DOCTYPE html> <html> <head> <title>The 文档的标题</title> <style> p { border: 2px solid #cccccc; color: #8ebf42; padding-top: 15%; } </style> </head> <body> <h2>Padding-top 属性示例</h2> <p>经历过风雨,才懂得阳光的温暖。</p> </body> </html>
padding-top 属性设置元素顶部的填充空间。
负值无效。
此属性不影响内联元素,例如 <span>。
初始值 | 0. |
---|---|
应用于 | 所有元素,除非其display属性设置为table-row-group, table-header-group, table-footer-group, table-row, table-column-group and table-column。它还适用于::first-letter伪元素。 |
继承 | 无效 |
可动画的 | 是的。填充空间是有动画的。 |
版本 | CSS1 |
DOM 语法 | object.Style.Paddingtop =“10px”; |
CSS padding-top 属性值说明
值 | 描述 |
---|---|
length | 在PX,Pt,cm等中设置顶部填充。默认值为0。 |
% | 在包含元素的宽度的百分比中设置顶部填充。 |
initial | 使属性使用其默认值。 |
inherit | 从父母元素继承属性。 |
日期:2020-06-02 22:14:43 来源:oir作者:oir