css中Margin和padding屬性的區別

來源:互聯網
上載者:User

margin:層的邊框以外留的空白

padding:層的邊框到層的內容之間的空白

 

padding-top padding-left padding-right padding-bottom

margin-top margin-left margin-right margin-bottom

 

上下左右間隙寬度相同

.d1 {padding:1cm}

.d1{margin:1cm}

 

也可以分別設定間隙 ,順序 是上,右,下,左。樣本如下:

.d1 {padding:1cm 2cm 3cm 4cm}

.d1{margin:1cm 2cm 3cm 4cm}

上面的代碼錶示,上間隙為1cm,右間隙為2cm,下間隙為3cm,左間隙為4cm 。

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.