2.常用样式.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. /* 1.标签选择器
  9. 标签名称 {样式}
  10. */
  11. #box1 {
  12. /* 宽度 */
  13. /* 像素单位 px */
  14. width: 800px;
  15. /* 高度 */
  16. height: 800px;
  17. /* 背景 复合属性
  18. background: color repeat position image;
  19. */
  20. /* background: red; */
  21. /*
  22. 背景色:background-color
  23. 背景图:background-image:url("路径")
  24. 背景平铺:background-repeat
  25. repeat 平铺 no-repeat 不平铺 repeat-x 横轴平铺 repeat-y 纵轴平铺
  26. 背景尺寸:background-size
  27. contain 等比例放到最大 cover 全覆盖
  28. 背景位置:background-position
  29. top left center right bottom 直接给距离也可以
  30. */
  31. /* background-color: rgb(227, 227, 30); */
  32. /* background-image: url("../html/images/img01.gif"); */
  33. /* background-repeat: no-repeat; */
  34. /* background-size:contain; */
  35. /* background-position: 10%; */
  36. background: red no-repeat center url("../html/images/img01.gif");
  37. }
  38. #box2 {
  39. width: 300px;
  40. height: 300px;
  41. background: blue;
  42. }
  43. /* 写样式的时候 相同标签相同样式 后面的会覆盖前面的 */
  44. /* id选择器
  45. 在body标签内
  46. 在开始标签中添加 id='名字'
  47. 在style中
  48. #名字 {样式...}
  49. */
  50. </style>
  51. </head>
  52. <body>
  53. <div id="box1"></div>
  54. <div id="box2"></div>
  55. </body>
  56. </html>