您好,登錄后才能下訂單哦!
一、浮動(dòng)
left 元素向左浮動(dòng)
right 元素向右浮動(dòng)
none 元素不浮動(dòng)
inherit 從父級(jí)繼承浮動(dòng)屬性
#fd{ width: 100px; height: 100px; background-color: red; float: left; } #sd{ width: 100px; height: 100px; background-color: blue; float: left; } #td{ width: 100px; height: 100px; background-color: green; float: left; } #container{ width: 400px; height: 500px; background-color: darkgray; }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>浮動(dòng)</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="container"> <div id="fd"></div> <div id="sd"></div> <div id="td"></div> </div> </body> </html>
二、clear屬性
去掉浮動(dòng)屬性(包括繼承來(lái)的屬性)
left、right 去掉元素向左、向右浮動(dòng)
both 左右兩側(cè)均去掉浮動(dòng)
inherit 從父級(jí)繼承來(lái)clear的值
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>浮動(dòng)</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div id="container"> <div id="fd"></div> <div id="sd"></div> <div id="td"></div> <div id="text">HelloWorld!</div> </div> </body> </html>
#fd{ width: 100px; height: 100px; background-color: red; float: left; } #sd{ width: 100px; height: 100px; background-color: blue; float: left; } #td{ width: 100px; height: 100px; background-color: green; float: left; } #container{ width: 280px; height: 500px; background-color: darkgray; } #text{ clear: left; }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。