box-sizing

爱被打了一巴掌 2022-06-03 09:17 233阅读 0赞
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. <style>
  7. div{
  8. width: 160px;
  9. height: 80px;
  10. padding: 20px;
  11. border: 8px solid red;
  12. background: yellow;
  13. }
  14. .content-box{
  15. box-sizing: content-box;
  16. }
  17. .border-box{
  18. box-sizing: border-box;
  19. }
  20. </style>
  21. </head>
  22. <body>
  23. <div class="content-box">Content box</div><br/>
  24. <div class="border-box">Border box</div>
  25. <script>
  26. /*
  27. content-box:
  28. This is the initial and default value as specified by the CSS standard. The width and height properties are measured including only the content, but not the padding, border or margin.
  29. 默认值。宽度和高度属性仅包括内容,不包含内边距,边框和外边距。
  30. border-box:
  31. The width and height properties include the content, the padding and border, but not the margin.
  32. 宽度和高度属性包含内容,内边距和边框,但不包含外边距。
  33. */
  34. </script>
  35. </body>
  36. </html>

20171225095237971

参考链接:

点击打开链接

发表评论

表情:
评论列表 (有 0 条评论,233人围观)

还没有评论,来说两句吧...

相关阅读