關於css布局的一些個人理解。(只是自己理解,不對的地方勿噴),css布局
兩列布局(左側寬度固定,右側自適應)
例如:
<!doctype html><html><head><title>左部寬度固定,右部自適應</title><meta charset="utf-8"/><style type="text/css"> *{ margin:0px; padding:0px; font-size:14px; } div{ height:600px; } .left{ width:300px; background:red; float:left; } body div.right{ background:green; margin-left:300px; }</style> <link rel="stylesheet" type="text/css" href=""/></head><body> <div class="left">左部</div> <div class="right">右部</div></body></html>
三列布局,(左右寬度固定,中間自適應);
<!doctype html><html><head><title>左右寬度固定,中間自適應</title><meta charset="utf-8"/><style type="text/css"> *{ margin:0px; padding:0px; font-size:14px; } div{ height:700px; } .left{ width:300px; background:red; float:left; } .right{ width:400px; background:yellow; float:right; } .center{ background:blue; margin:0 400px 0 300px; }</style></head><body><div class="left">左</div><div class="right">右</div><div class="center">中</div></body></html>