【发布时间】:2010-12-23 02:04:24
【问题描述】:
我不知道这是否是一个常见问题,但我目前在网络上找不到解决方案。 我想将两个 div 包裹在另一个 div 中,但是里面的这两个 div 必须对齐同一级别(例如:左边一个占 WrapdDiv 的 20% 宽度,右边一个占另一个 80%)。为了达到这个目的,我使用了下面的示例 CSS。但是,现在 wrap DIV 并没有将这些 div 全部包装起来。 wrap div 的高度比包含在里面的两个 div 小。我如何确保 wrap Div 具有最大的高度作为包含的 div?谢谢!!!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>liquid test</title>
<style type="text/css" media="screen">
body
{
margin: 0;
padding: 0;
height:100%;
}
#nav
{
float: left;
width: 25%;
height: 150px;
background-color: #999;
margin-bottom: 10px;
}
#content
{
float: left;
margin-left: 1%;
width: 65%;
height: 150px;
background-color: #999;
margin-bottom: 10px;
}
#wrap
{
background-color:#DDD;
height:100%;
}
</style>
</head>
<body>
<div id="wrap">
<h1>wrap1 </h1>
<div id="nav"></div>
<div id="content"><a href="index.htm">< Back to article</a></div>
</div>
</body>
</html>
【问题讨论】: