Style paddingTop egenskab
- Forrige side paddingRight
- Næste side pageBreakAfter
- Gå tilbage til forrige niveau HTML DOM Style objekt
定义和用法
paddingTop
Sets or returns the top inner padding of an element.
Inner padding attributes define the space between the element's border and its content.
margin property and Padding property Inserts space around the element. However, the difference is that margin inserts space around the border, while padding inserts space inside the element's border.
See also:
CSS Tutorial:CSS indre kantlinje
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
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"
Attribute 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 representing the top inner padding of an element. |
CSS version: | CSS1 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Forrige side paddingRight
- Næste side pageBreakAfter
- Gå tilbage til forrige niveau HTML DOM Style objekt