CSS负边距自适应布局三例

单列定宽单列自适应布局:

CSS负边距自适应布局三例
<!DOCTYPE HTML>
<html>
<head>
<meta charset=”UTF-8″>
<title>单列定宽单列自适应布局</title>
<style type=”text/css”>
* {margin:0;padding:0;}
.cont, .side {float:left;}
.cont {width:100%;}
.main {margin-right:200px;background:#DDDDDD;}
.side {margin-left:-200px;width:200px;background:#F7F7F7;}
</style>
</head>
<body>
<div class=”cont”>
<div class=”main”>main</div>
</div>
<div class=”side”>side</div>
</body>
</html>
CSS负边距自适应布局三例

左右定宽中间自适应布局:

CSS负边距自适应布局三例
<!DOCTYPE HTML>
<html>
<head>
<meta charset=”UTF-8″>
<title>左右定宽中间自适应布局</title>
<style type=”text/css”>
* {margin:0;padding:0;}
.cont, .side, .sub-main {float:left;}
.cont {width:100%;}
.main {margin-right:200px;margin-left:300px;background:#DDDDDD;}
.side {margin-left:-200px;width:200px;background:#F7F7F7;}
.sub-main {margin-left:-100%;width:300px;background:#F7F7F7;}
</style>
</head>
<body>
<div class=”cont”>
<div class=”main”>main</div>
</div>
<div class=”side”>side</div>
<div class=”sub-main”>sub-main</div>
</body>
</html>
CSS负边距自适应布局三例

两列等高自适应布局:

CSS负边距自适应布局三例
<!DOCTYPE HTML>
<html>
<head>
<meta charset=”UTF-8″>
<title>两列等高自适应布局</title>
<style type=”text/css”>
* {margin:0;padding:0;}
.layout {overflow:hidden;}
.cont, .side {float:left;padding-bottom:9999px;margin-bottom:-9999px;}
.cont {width:100%;}
.main {margin-right:200px;background:#DDDDDD;}
.side {margin-left:-200px;width:200px;background:#F7F7F7;}
</style>
</head>
<body>
<div class=”layout”>
<div class=”cont”>
<div class=”main”>
main
<br/><br/><br/><br/><br/><br/><br/>
</div>
</div>
<div class=”side”>side</div>
</div>
</body>
</html>
CSS负边距自适应布局三例

CSS负边距自适应布局三例

上一篇:利用IE/FF的不同识别CSS来使用浏览器兼容问题


下一篇:Java标识符以及关键字