常用样式.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /* 像素 px */
  10. /* 宽度 width */
  11. /* 高度 height */
  12. /* 颜色 color */
  13. /* 背景 background */
  14. /* 背景色 background-color */
  15. /* 背景图片 background-image:url("引入图片路径") */
  16. /* 背景平铺 background-repeat:
  17. no-repeat 不平铺
  18. repeat-x 横向平铺
  19. repeat-y 纵向平铺
  20. repeat 平铺
  21. */
  22. /* 背景尺寸 background-size
  23. cover 全覆盖
  24. contain 等比例放大
  25. */
  26. /*
  27. 背景位置 background-position
  28. 一个值:
  29. 同时代表x y轴
  30. 两个值的情况:
  31. 1.x轴 y轴
  32. 2.right/left top/bottom
  33. */
  34. /*
  35. background 复合属性
  36. background: color image repeat position;
  37. */
  38. width: 300px;
  39. height: 300px;
  40. color: red;
  41. background-image: url("./images/img01.gif");
  42. /* background:yellowgreen; */
  43. /* background-color: yellow; */
  44. background-repeat: no-repeat;
  45. /* background-size: cover; */
  46. background-position:200px;
  47. }
  48. .main {
  49. width: 900px;
  50. height: 400px;
  51. /* background: red url("./images/img01.gif") no-repeat; */
  52. background-color: blueviolet;
  53. background-image: url('./images/img01.gif');
  54. background-repeat: no-repeat;
  55. /* background-size: cover; */
  56. background-position: right bottom;
  57. }
  58. </style>
  59. </head>
  60. <body>
  61. <!-- <div class="box"></div> -->
  62. <div class="main"></div>
  63. </body>
  64. </html>