123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <!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>
- #box {
- width: 800px;
- height: 800px;
- margin: 0 auto;
- border: 3px solid #000;
- }
- #part1 {
- width: 200px;
- height: 200px;
- /* display: inline-block; */
- float: left;
- background-color: #f00;
- }
- #part2 {
- width: 230px;
- height: 230px;
- /* margin-top: 10px; */
- /* display: inline-block; */
- float: left;
- background-color: #ff0;
- }
- #part3 {
- width: 200px;
- height: 200px;
- /* float: left; */
- background-color: #00f;
- }
- /*
- 当想让元素在一行展示时
- 使用浮动
- float:left/right/none
- 使元素脱离文档流 不占位
- 排版:
- 文档排版
- 浮动
- */
- </style>
- </head>
- <body>
- <div id="box">
- <div id="part1"></div>
- <div id="part2"></div>
- <div id="part3"></div>
- </div>
- </body>
- </html>
|