Style paddingTop 属性
- 上一页 paddingRight
- 下一页 pageBreakAfter
- 返回上一层 Object ng Style ng HTML DOM
定义和用法
paddingTop
Property sets or returns the top inner padding of the element.
The inner padding property defines the space between the element's border and its content.
margin Property and Padding Property They both insert space around the element, but the difference is that margin inserts space around the border, while padding inserts space within the element's border.
See Also:
CSS Tutorial:CSS 内边距
CSS Reference Manual:padding-top Property
HTML DOM Reference Manual:Padding Property
Instance
Example 1
Set the top inner padding of the <div> element:
document.getElementById("myDiv").style.paddingTop = "50px";
Example 2
Change the top inner padding of the <div> element back to "normal":
document.getElementById("myDiv").style.paddingTop = "0px";
Example 3
Returns the top inner padding of the <div> element:
alert(document.getElementById("myDiv").style.paddingTop);
Example 4
Difference between marginTop and paddingTop:
function changeMargin() { document.getElementById("myDiv").style.marginTop = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingTop = "100px"; }
Syntax
Return paddingTop property:
object.style.paddingTop
Set paddingTop property:
object.style.paddingTop = "%|length|initial|inherit"
Property Value
Value | Description |
---|---|
% | Defined by the percentage of the parent element's width for the top inner padding. |
length | Defined by length units for the top inner padding. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default value: | 0 |
---|---|
Return value: | A string that represents the top inner padding of an element. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 paddingRight
- 下一页 pageBreakAfter
- 返回上一层 Object ng Style ng HTML DOM