03 2008

无js实现div+css左右高度自适应

Published by at 14:17 under CSS,Web技术

以下代码实现了无js实现div+css左右高度自适应,具体应用视情况而定。

<!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=gb2312″ />
<title>左右自适应高度</title>
<style type=”text/css”>
.outer{display:table}
.outer,.inner,.a,.b{
width:200px;
}
.outer{
margin:10px 0 10px 200px;
background:red;
color:#fff;
}
.inner{
position:relative;
float:left;
margin-left:-200px;
background:blue;
}
.a{
float:left;
}
.b{
position:relative;
float:right;
margin-right:-200px;
}
</style>
</head>
<body>
<div class=”outer”>
   <div class=”inner”>
     <div class=”a”>一边底</div>
     <div class=”b”>另一边高<br />
       <br />
       <br />
       <br />
       . 这个是另一边高,一边底,这样一边底就能自适应另一边的高度了。</div>
   </div>
</div>
</body>
</html>

One response so far

One Response to “无js实现div+css左右高度自适应”

  1. 笨二十一on 04 四 2008 at 01:26

    虽然可以实现左右自动平衡,但设置起来有一定麻烦,
    尤其是修改的时候

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.