| 12345678910111213141516171819202122232425262728293031 |
- <!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: 200px;
- height: 200px;
- background-color: red;
- color: white;
- font-size: 30px;
- text-align: center;
- line-height: 200px;
- /* display: inline-block; */
- /* float 表示浮动 可以将块元素横向排列 两个值:left向左 right向右 none不浮动 */
- float: right;
- }
- </style>
- </head>
- <body>
- <!-- 浮动元素会脱离文档流 -->
- <!-- 文档流:正常的文档排列顺序 -->
- <!-- 脱离文档流会导致父元素高度塌陷 -->
- <div class="box">1</div>
- <div class="box">2</div>
- <div class="box">3</div>
- </body>
- </html>
|