php - CSS/PHP : how to solve this div float problem/odd even loop in array

标签 php html css

我的代码在这篇文章的末尾。

我究竟如何让“框 3”与“框 1”相邻或与“框 1”内的内容对齐,而不是在“框 2”的末尾对齐自身。

这里重要的是所有四个框必须使用相同的样式 -(样式 2)因为它在数组调用中使用。

这是现在的情况以及我正在努力实现的目标:

http://img524.imageshack.us/img524/1408/lastexample.gif

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {border:1px solid #000000; width:620px; position:relative;
}
.style2 {border:1px solid #000000; width:300px; float:left;}
-->
</style>
</head>

<body>
<div class="style1">

    <div class="style2">box 1<br>
      <br>
      <br>
    </div>
    <div class="style2">box 2<br>
      <br>
      <br>
      <br>
  </div>

    <div class="style2">box 3<br>
      <br>
    </div>
    <div class="style2">box 4<br>
      <br>
      <br>
    </div>
</div>
</body>
</html>

最佳答案

不知道有什么方法可以通过对所有内部 DIV 使用单个类来使用纯 CSS 来实现这一点。你想要像 Masonry 这样的东西.

Think of Masonry as the flip side of CSS floats. Where as floats arrange elements horizontally then vertically, Masonry arranges them vertically then horizontally. The result leaves no vertical gaps between elements of varying height, just like a mason fitting stones in a wall.

-The Masonry home page

关于php - CSS/PHP : how to solve this div float problem/odd even loop in array,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1401269/

相关文章:

javascript - 单击按钮时动态添加选择框、文本框和日期并将这些值插入数据库

HTML5 应用程序 - 避免每次下载?

jquery - iPad 和视差效果

html - 如何在我的 HTML 中找到未使用的类?

php - 人工输入的智能日期范围解析?

javascript - 带有自定义 header 的 XmlHttpRequest : Response for preflight doesn't pass access control check

PHP Ajax XMLHttpRequest popen 实时进度

javascript - Bootstrap 表单输入浮点值问题

javascript - 我应该使用什么技术组合来制作具有新 HTML 5 中的自定义用户界面的视频播放器

javascript - 如何更改 HTML 文件输入的默认消息 "Please enter a value with a valid mimetype."