123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- <style>
- /* 1.标签选择器
- 标签名称 {样式}
- */
- #box1 {
- /* 宽度 */
- /* 像素单位 px */
- width: 800px;
- /* 高度 */
- height: 800px;
- /* 背景 复合属性
- background: color repeat position image;
- */
- /* background: red; */
- /*
- 背景色:background-color
- 背景图:background-image:url("路径")
- 背景平铺:background-repeat
- repeat 平铺 no-repeat 不平铺 repeat-x 横轴平铺 repeat-y 纵轴平铺
- 背景尺寸:background-size
- contain 等比例放到最大 cover 全覆盖
- 背景位置:background-position
- top left center right bottom 直接给距离也可以
- */
- /* background-color: rgb(227, 227, 30); */
- /* background-image: url("../html/images/img01.gif"); */
- /* background-repeat: no-repeat; */
- /* background-size:contain; */
- /* background-position: 10%; */
- background: red no-repeat center url("../html/images/img01.gif");
- }
- #box2 {
- width: 300px;
- height: 300px;
- background: blue;
- }
- /* 写样式的时候 相同标签相同样式 后面的会覆盖前面的 */
- /* id选择器
- 在body标签内
- 在开始标签中添加 id='名字'
- 在style中
- #名字 {样式...}
- */
- </style>
-
- </head>
- <body>
- <div id="box1"></div>
- <div id="box2"></div>
- </body>
- </html>
|