2.常用样式.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. /**
  9. 标签选择器
  10. 标签名字 {样式...}
  11. id选择器
  12. 在body标签中
  13. 在开始标签里 通过id="名字"
  14. 在style标签里
  15. #名字 {样式...}
  16. */
  17. div {
  18. /* 宽度 */
  19. /* 单位 px */
  20. width: 300px;
  21. /* 高度 */
  22. height: 200px;
  23. /* 背景色 */
  24. background-color: red;
  25. }
  26. #second {
  27. /* 宽度 */
  28. /* 单位 px */
  29. width: 1000px;
  30. /* 高度 */
  31. height: 500px;
  32. /* 复合属性 背景
  33. background:color position repeat image;
  34. */
  35. background: yellow url("../images/img01.gif") center no-repeat;
  36. /* 背景色 */
  37. /* background-color: yellow; */
  38. /* 背景图 */
  39. /* background-image: url("../images/img01.gif"); */
  40. /* 背景平铺 */
  41. /* 不平铺 */
  42. /* background-repeat: no-repeat; */
  43. /* x轴平铺 */
  44. /* background-repeat: repeat-x; */
  45. /* y轴平铺 */
  46. /* background-repeat: repeat-y; */
  47. /* 全部平铺 */
  48. /* background-repeat: repeat; */
  49. /* 背景图位置
  50. x轴 y轴
  51. */
  52. /* background-position: 50px center; */
  53. /*
  54. 背景尺寸 background
  55. contain 等比例放大
  56. cover 覆盖
  57. */
  58. /* background-size: cover; */
  59. }
  60. </style>
  61. </head>
  62. <body>
  63. <div></div>
  64. <div id="second"></div>
  65. <!-- <img src="../images/img01.gif" alt=""> -->
  66. </body>
  67. </html>