3_基础样式-背景.html 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. <style>
  9. /* 宽高 */
  10. /* 背景 */
  11. #div1{
  12. /* 宽 度 */
  13. width:1000px;
  14. height:600px;
  15. /* 背景 复合属性 */
  16. /* background: red; */
  17. background-color: red;
  18. /* 背景图片 url(路径) */
  19. background-image: url(images/img02.jpeg);
  20. /* 背景图片重复 默认 repeat重复|no-reapeat 不重复 */
  21. background-repeat:no-repeat ;
  22. /* 背景图片位置 默认是0 0 第一个值水平 第二个值垂直
  23. 水平 left center right
  24. 垂直 top center bottom
  25. */
  26. background-position:center center;
  27. }
  28. </style>
  29. </head>
  30. <body>
  31. <div id="div1">
  32. </div>
  33. </body>
  34. </html>