Style padding hanyar
- Na wuce shugaba overflowY
- Na wuce shugaba paddingBottom
- Na wuce kashi Obhaji HTML DOM Style
定义和用法
padding
属性设置或返回元素的内边距。
此属性可以采用一到四个值:
margin 属性 和 padding property 都在元素周围插入空间。但是,不同之处在于,margin 在边框周围插入空间,而 padding 在元素的边框内插入空间。
- irin dakiya, misali: div {padding: 50px} - dukkan irti-irti na gaba za'a kare 50px
- irin dakiya, misali: div {padding: 50px 10px} - irti-irti na gaba da kai tsakiya da kai yankin 50px, irti-irti na gaba da kai yankin 10px
- Three values, for example: div {padding: 50px 10px 20px} - the top inner padding is 50px, the left and right inner padding is 10px, and the bottom inner padding is 20px
- Four values, for example: div {padding: 50px 10px 20px 30px} - the top inner padding is 50px, the right inner padding is 10px, the bottom inner padding is 20px, and the left inner padding is 30px
See also:
CSS tutorial:CSS padding
CSS reference manual:padding property
Instance
Example 1
Set the inner padding of the <div> element:
document.getElementById("myDiv").style.padding = "50px 10px 20px 30px";
Example 2
Change all four sides of the <div> element's inner padding to "25px":
document.getElementById("myDiv").style.padding = "25px";
Example 3
Returns the inner padding of the <div> element:
alert(document.getElementById("myDiv").style.padding);
Example 4
Difference between margin and padding properties:
function changeMargin() { document.getElementById("myDiv").style.margin = "100px"; } function changePadding() { document.getElementById("myDiv2").style.padding = "100px"; }
Syntax
Return padding property:
object.style.padding
Set padding property:
object.style.padding = "%|length|initial|inherit"
Attribute value
Value | Description |
---|---|
% | Define inner padding with percentage of the parent element's width. |
length | Define inner padding with length units. |
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 inner padding of an element. |
CSS version: | CSS1 |
browser supports
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Girmama | Girmama | Girmama | Girmama | Girmama |
- Na wuce shugaba overflowY
- Na wuce shugaba paddingBottom
- Na wuce kashi Obhaji HTML DOM Style