练习仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.5 KiB

5 days ago
  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. </head>
  8. <style>
  9. .bac{
  10. width: 500px;
  11. height: 510px;
  12. background-color: green;
  13. background-image: url("1.webp");
  14. /* 平铺方式:
  15. repeat:默认方式;
  16. repeat-x:只水平平铺
  17. repeat-y:只垂直平铺
  18. no-repeat:不平铺
  19. */
  20. background-repeat: repeat-x;
  21. /* length:只调整高或宽,另一个值等比例改变
  22. percentage:设定百分比
  23. cover:锁定比例并且充满容器,多余部分不显示
  24. contain:锁定比例且保证图片最大 */
  25. background-size: 500px;
  26. }
  27. .bac2{
  28. width: 1000px;
  29. height: 1100px;
  30. background-color: green;
  31. background-image: url("2.webp");
  32. background-repeat: no-repeat;
  33. background-size: contain;
  34. }
  35. .bac3{
  36. width: 200px;
  37. height: 100px;
  38. background-color: green;
  39. background-image: url("2.webp");
  40. background-repeat: no-repeat;
  41. /* 用left,right,top,bottom组合确定图像起始位置
  42. x% y%:只设置一个另一个默认为50%。 都不设置默认为0% 0%;
  43. xpos ypos:像素表示 */
  44. background-position: left center;
  45. }
  46. </style>
  47. <body>
  48. <div class="bac"></div>
  49. <div class="bac2"></div>
  50. <div class="bac3"></div>
  51. </body>
  52. </html>