我不知道这是否是一个普遍的问题,但是到目前为止,我在网络上找不到解决方案。我想要在一个 div 元素中包含两个 div 元素,然而这两个内部元素必须对齐(例如:左边的元素占所包含 div 元素的 20% 宽度,右边的元素占据剩下的 80% 宽度)。为了实现这个目的,我使用了以下 CSS 示例。然而,现在包含这些 div 元素的外层 div 元素没有完全包裹它们。外层 div 元素的高度比内部的两个 div 元素小。我该如何确保外层 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>
.container { word-wrap: break-word; }
和.container img { max-width: 100%; height: auto; }
可以使大型内容表现更好。 - Kos