简答:
看看Faux Columns trick,然后你可以概括to three columns too。
长答案
如果您真的想自己学习做这件事,请确保您知道inline elements 和block level elements 之间的区别。一旦你知道了区别,并且可以识别一些内联 HTML 元素和块级 HTML 元素,请检查display CSS 属性,并确保你永远不会做这样的事情:
<!-- monumental fail -->
<a href="#">
<div style="height:200px;width:200px;">
They wanted the anchor to have height/width
And didn't realize that a `display:block` CSS property
would allow the anchor element a height/width
</div>
</a>
我还建议对 CSS 属性 float 和 clear 以及 float 和 margin 和 overflow-y 之间的关系建立一个坚实的前后理解。举这个例子,开始改变这三个属性的值,看看会发生什么:
<div style="background:yellow;overflow-y:hidden;">
<div style="width:100px;float:left;">
Left Column
</div>
<div style="height:500px;margin-left:101px;background:blue;">
Main Column
</div>
</div>
...一旦你明白了,看看Faux Columns trick,然后你可以概括to three columns too。
如果你再进一步,开始使用CSS positioning...
<div style="border:2px solid black;margin:50px;border:2 px solid yellow;height:1500px;width:500px;">
<div style="height:50px;border:2px solid red;position:absolute;top:0px;">
Absolute; Top (take note that its parent element is statically positioned...)
</div>
<div style="border:2px solid blue;position:relative;left:100px;height:200px;padding-top:50px;">
Relative; see how it's just offset from where it is normally?
<div style="height:50px;border:2px solid red;position:absolute;top:0px;">
Absolute; Top (take note that its parent element is NOT statically positioned hence why it's not in the same place as the last absolutely positioned div)
</div>
</div>
<div style="height:50px;border:2px solid green;position:fixed;bottom:0px;">
Fixed; bottom (even there when you scroll)
</div>
</div>
...那我觉得你可以从“CSS基础知识”一步步提升到“精通”了。