Style paddingTop Eigenschaft
- Vorherige Seite paddingRight
- Nächste Seite pageBreakAfter
- Zurück zur vorherigen Ebene HTML DOM Style-Objekt
定义和用法
paddingTop
The property sets or returns the top inner padding of an element.
The inner padding property defines the space between the element's border and its content.
margin property and padding property They all insert space around the element. However, the difference is that margin inserts space around the border, while padding inserts space within the element's border.
See also:
CSS Tutorial:CSS-Innenabstand
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
Reset the top inner padding of the <div> element to "normal":
document.getElementById("myDiv").style.paddingTop = "0px";
Example 3
Return 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 |
---|---|
% | Top inner padding is defined as a percentage of the parent element's width. |
length | Top inner padding is defined by length units. |
initial | Set this property to its default value. See also initial. |
inherit | This property inherits from its parent element. See also 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 |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
- Vorherige Seite paddingRight
- Nächste Seite pageBreakAfter
- Zurück zur vorherigen Ebene HTML DOM Style-Objekt