Style paddingLeft 属性
- 上一页 paddingBottom
- 下一页 paddingRight
- 返回上一层 Object ng Style ng HTML DOM
定义和用法
paddingLeft
Definition and Usage
paddingLeft Sets or returns the left inner padding of the element. padding-left Property margin Property
and
It 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.CSS 内边距
See Also:CSS Tutorial:
CSS Reference Manual:padding-left Property
HTML DOM Reference Manual:
Padding Property
Instance
Example 1
Set the left inner padding of the <div> element:
Example 2
Reset the left inner padding of the <div> element to "normal":
Example 3
Returns the left inner padding of the <div> element:
alert(document.getElementById("myDiv").style.paddingLeft);
Example 4
Difference between marginLeft and paddingLeft:
function changeMargin() { document.getElementById("myDiv").style.marginLeft = "100px"; } function changePadding() { document.getElementById("myDiv2").style.paddingLeft = "100px"; }
Syntax
Return paddingLeft Property:
object.style.paddingLeft
Set paddingLeft Property:
object.style.paddingLeft = "%|length|initial|inherit"
Property Value
Value | Description |
---|---|
% | Defined by the percentage of the parent element width to define the left inner padding. |
length | Defined by length unit to define the left 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 left inner padding of an element. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
支持 | 支持 | 支持 | 支持 | 支持 |
- 上一页 paddingBottom
- 下一页 paddingRight
- 返回上一层 Object ng Style ng HTML DOM