【发布时间】:2017-12-31 21:53:05
【问题描述】:
我有几个 div 需要安排,但我卡住了。它应该是这样的
我已经为此工作了几个小时,但情况不会好转。 这是我到目前为止写的代码。我认为专业人士有一个简单的解决方案。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
#wrapper {
width: 600px;
margin: 0 auto;
}
#content_3 {
float: left;
background: #bbb;
width: 200px;
}
#content_2 {
float: left;
width: 200px;
background: #aaa;
}
#content_4 {
float: right;
width: 200px;
background: #ddd;
}
#content_1 {
float:left;
width: 400px;
margin: 0 auto;
background: #eee;
}
</style>
</head>
<body>
<div id="wrapper">
<div>
<div id="content_1">content_1</div>
<div id="content_2">content_2</div>
<div id="content_3">content_3</div>
</div>
<div id="content_4">content_4</div>
</div>
</body>
</html>
有人可以帮忙吗?
两种解决方案都对我有用,但 DIV 2 的内容正在增加,因此内容 3 和 4 正在下降。我怎样才能解决这个问题? Conten_3 和 4 应位于 content_1 下方
【问题讨论】:
-
您的文档类型是自 1999 年以来不应用于新网页的文档类型。将其更新为当前所需的文档类型:
<!DOCTYPE html> -
Masonry layout with css3 flex Search on SO 或 Google 的“砌体布局”可能重复,并找到许多相同的答案。