css3基礎 box-sizing 設置盒模型(邊線與padding不改盒子的大小)
阿新 • • 發佈:2018-02-11
鍛煉 author har con ast 學習 tca padding set
禮悟:
公恒學思合行悟,尊師重道存感恩。葉見尋根三返一,江河湖海同一體。
虛懷若谷良心主,願行無悔給最苦。讀書鍛煉養身心,誠勸且行且珍惜。
ide:visual studio 2017
browser:Chrome
os:win7
代碼
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="author" content="https://www.cnblogs.com/jizuiku"/> <title></title> <style type="text/css"> .content-b { width:150px; height:150px; background-color:brown; /* 默認值 */ box-sizing:content-box; padding:20px; border:10px solid red; } .border-b { width:150px; height:150px; background-color:darkorange; /* width包含了 padding 和 border */ box-sizing:border-box; padding:20px; border:10px solid red; margin:10px; }</style> </head> <body> <div class="content-b"></div><!-- 這個盒子被撐的好大 --> <div class="border-b"></div> </body> </html>
效果
CSS3優秀,值得學習。
學習資源: www.w3cschool.cn + itcast和itheima視頻庫 + 清凈的心地。
如果您有公開的資源,可以分享給我的話,用您的資源學習也可以。
博文是觀看視頻後,融入思考寫成的。博文好,是老師講得好。博文壞,是 給最苦 沒認真。
css3基礎 box-sizing 設置盒模型(邊線與padding不改盒子的大小)