css - 如何在典型布局中设置多个 div

标签 css html

对于我的元素网站首页,我一直在尝试设置 div,如下图所示。 但我无法获得所需的结果。请帮忙。

Example Image

主 div(黑色边框)的宽度为 910px。 Div-1、2 和 5 的宽度相同,均为 900px。但是 Div-3 和 Div-4 是不同的,因为它们是内容页面和侧边栏。 Div-3 为 635px 宽,Div-4 为 255px 宽。 如上图所示,Div-3 进一步分为子分区。 所有 div 的高度都应为自动。

如何设置 CSS 和 HTML?

最佳答案

当您有多个水平相邻的 div 时,您需要使用 float (在您的情况下,div 3 和 4,以及所有 div 3 subdivs)。 Here是一个不错的小教程,会对您有很大帮助。

For variable height columns, absolute positioning does not work, so let's come up with another solution.

We can "float" an element to push it as far as possible to the right or to the left, and allow text to wrap around it. This is typically used for images, but we will use it for more complex layout tasks (because it's the only tool we have).

编辑

更多教程:http://www.html.net/tutorials/css/lesson13.phphttp://www.tizag.com/cssT/float.php .

您也可以尝试使用 display: inline-block; 来获得类似的结果。

关于css - 如何在典型布局中设置多个 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14513979/

相关文章:

html - 我的 Bootstrap 导航栏侧面菜单没有出现在内部内容上方

html - 将 JSP 变量传递给 html 标记的属性的最佳做法是什么?

javascript - 从数组中删除彼此范围内的对象

css - 如何垂直对齐嵌套在无序列表中的 anchor 元素内的文本

html - webkit 上 HTML 元素的 SVG 掩码

javascript - Canvas 上下文坐标不一致

css - 使用 CSS 在 Bootstrap 中定位 "Parallax"

html - DIV 高度设置为屏幕的百分比?

ruby-on-rails-3 - 如何在 Rails 中用 div 包装 date_select 的每个选择?

html - 如何让滑动导航面板的按钮元素随 HTML 和 CSS 一起旋转?