您好,登錄后才能下訂單哦!
小編給大家分享一下HTML中內(nèi)邊距屬性、外邊距屬性的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
HTML連載38-內(nèi)邊距屬性、外邊距屬性
一、內(nèi)邊距屬性
1.定義:邊框和內(nèi)容之間的距離就是內(nèi)邊距
2.分開寫
padding-top:數(shù)字px; padding-left:數(shù)字px; padding-bottom:數(shù)字px; padding-right:數(shù)字px;
3.連寫:
padding:上 右 下 左;
4.注意點(diǎn):
(1)給標(biāo)簽設(shè)置內(nèi)邊距之后,標(biāo)簽占有的寬度和高度會(huì)發(fā)生變化
(2)內(nèi)邊距也會(huì)有背景顏色
<style> div{ font-size: 25px; width:100px; height: 100px; border: 1px solid red; background-color: green; } .box1{ padding-top:20px; } .box2{ padding-left: 30px; } .box3{ padding-bottom: 40px; } .box4{ padding-right:50px; } .box5{ padding:40px 60px 70px 80px; } </style> <body> <div class="box1">我是段落一</div> <div class="box2">我是段落二</div> <div class="box3">我是段落三</div> <div class="box4">我是段落四</div> <div class="box5">我是段落五</div> </body>
二、外邊距屬性
1.定義:標(biāo)簽與標(biāo)簽之間的距離就是外邊距
2.分開寫:
margin-top:數(shù)值px; margin-left:數(shù)值px; margin-bottom:數(shù)值px; margin-left:數(shù)值px;
3.一起寫
margin:上 左 下 右;
4.例子
<style> span{ width: 100px; height:100px; background-color: red; margin:50px; border:2px solid black; } .box1{ margin-top:20px; } .box2{ margin-left:30px; } .box3{ margin-bottom: 40px; } .box4{ margin-rigth:50px; } .box5{ margin:60px 70px 80px 90px; } </style> </head> <body> <span class="box1">我是span</span><span class="box2">我是span</span><span class="box3">我是span</span><span class="box4">我是span</span><span class="box5">我是span</span> ?
5.注意點(diǎn):外邊距的那一部分是沒有背景顏色的。
以上是“HTML中內(nèi)邊距屬性、外邊距屬性的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。