初学 html5 写网页,想写一个 V2EX 这样的布局,如果用单独的 css 文件来布局就可以,如果写在 div 的 style 中, div 就会换行。这两种写法效果应该一样的呀。
a.css 内容:
.mcenter{margin:0 410px 0 210px; background:#ffe6b8; height:600px;}
.mright{width:400px; margin-bottom:-3000px; padding-bottom:3000px; background:#f0f3f9; float:right;}
html 为:
<!DOCTYPE html>
<html>
<head>
<title>布局实例</title>
<link rel="stylesheet" href="a.css" media="all">
<meta charset="utf-8"/>
</head>
<body>
<div class="mright">右边,无高度属性,自适应于最高一栏的高度</div>
<div class="mcenter">中间,高度 600 像素,左右两栏的高度与之自适应</div>
<div>
<div id="center" style="margin:0 410px 0 210px; background:#ffe6b8; height:600px;"></div>
<div id="sill" style="width:400px; margin-bottom:-3000px; padding-bottom:3000px; background:#f0f3f9; float:right;"></div>
</div>
</body>
</html>