1.脫離文檔流
目前我知道的是有三種方式來使標簽脫離文檔流
(1)浮動
(2)固定定位
(3)絕對定位
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>脫離文檔流的情況</title> <style> .c1 { height: 100px; width: 100px; background-color: red; /*float: right;*/ } .c2 { height: 100px; width: 100px; background-color: black; /*float: right; !* 浮動會使標簽脫離文檔流,使得C3標簽向上頂在了C2浮動前的位置 *!*/ /*position: absolute; !* 絕對定位也會導致標簽脫離文檔流 *!*/ /*left: 400px;*/ position: fixed; /* 固定定位也會導致標簽脫離文檔流 */ right: 100px; } .c3 { height: 200px; width: 200px; background-color: green; } </style> </head> <body> <div class="c1"></div> <div class="c2"></div> <div class="c3"></div> </body> </html>