為什么right這里在css設置中float:right就不能實現自適應了,像我這樣的不知道哪里錯了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>混合布局編程挑戰</title>
<style type="text/css">
body{ margin:0; padding:0; font-size:30px; color:#fff}
.top{background:grey;height:200px;}
.main{height:600px;background:red;}
.left{position:absolute;left:0;top:200px;height:600px;width:200px;background:blue;}
.right{float:right;background:green;height:600px;margin-left:300px;width:100%;}
.foot{height:200px;background:orange}
</style>
</head>
<body>
<div class="top">top</div>
<div class="main">
? ? <div class="right">right</div>
? ? <div class="left">left</div>
</div>
<div class="foot">foot</div>
</body>
</html>
2016-03-08
.right不要去設置浮動了;用margin去自適應;
你的代碼:
修改后的代碼:
效果圖:
2016-03-05
錯了 你把.right中float浮動改為left 就可以了!