3.常用样式.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. width: 300px;
  10. height: 300px;
  11. background-color: red;
  12. }
  13. #content {
  14. width: 100px;
  15. height: 100px;
  16. background-color: green;
  17. }
  18. #content {
  19. width: 100px;
  20. height: 100px;
  21. background-color: blue;
  22. }
  23. /*
  24. css样式中 后面的层级会覆盖前面的层级
  25. id选择器
  26. 写法:
  27. 在body里
  28. 开始标签中 id="xxx"
  29. 在style中
  30. #xxx {样式....}
  31. */
  32. #main {
  33. width: 1800px;
  34. height: 1700px;
  35. /* background-color: aqua; */
  36. background: red url("../images/1.jpg") no-repeat center;
  37. /* background-image: url("../images/1.jpg"); */
  38. border: 1px solid #000;
  39. /* background-repeat: repeat-y; */
  40. /* background-size: contain; */
  41. /* background-position: 50px 100px ; */
  42. }
  43. /*
  44. 背景 复合属性
  45. background:color image repeat position;
  46. 背景色 background-color
  47. 背景图 background-image:url("路径")
  48. 背景是否平铺 background-repeat
  49. no-repeat 不平铺
  50. repeat-x 横向平铺
  51. repeat-y 纵向平铺
  52. 背景尺寸 background-size
  53. cover 全覆盖
  54. contain 当前盒子等比例放到最大
  55. 背景位置 background-position
  56. 一个值:同时代表x y轴 :center
  57. 两个之:left/right top/bottom
  58. */
  59. </style>
  60. </head>
  61. <body>
  62. <div id="box">
  63. <div id="content"></div>
  64. </div>
  65. <div id="main">
  66. </div>
  67. </body>
  68. </html>