4.外边距.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>Document</title>
  7. <style>
  8. .box {
  9. overflow: hidden;
  10. }
  11. #container {
  12. width: 500px;
  13. height: 500px;
  14. background: #f00;
  15. float: left;
  16. /* margin-top: 50px;
  17. margin-left: 30px;
  18. margin-bottom: 50px;
  19. margin-right: 10px; */
  20. margin: 10px 30px 50px 100px;
  21. /*
  22. 外边距 margin
  23. 一个值 上下左右
  24. 两个值 上下 左右
  25. 三个值 上 左右 下
  26. 四个值 上 右 下 左
  27. */
  28. }
  29. .main1 {
  30. width: 200px;
  31. height: 200px;
  32. background: #ff0;
  33. }
  34. .main2 {
  35. width: 200px;
  36. height: 200px;
  37. background: #f0f;
  38. float: left;
  39. }
  40. </style>
  41. </head>
  42. <body>
  43. <div class="box">
  44. <div id="container"></div>
  45. <div class="main2"></div>
  46. </div>
  47. <div class="main1"></div>
  48. </body>
  49. </html>