开发者

HTML/CSS: Having floated element all the way

I want to keep my floated element called leftPanel follow all the time.

I do not want to specify height.

How can I do that?

Example:

|floated element |     main content here
|floated         |     text is here and the
| stops          |     floated content <-
|  here          |     keeps following until
|                |     main content also ends
|                |     main content here
|                |     main content here
|                |     main content here
|                |     main content here
|                |     main content here
|                |     m开发者_JAVA技巧ain content here
|                |     ends here, and it also ends here.

Currently it looks like this:

    |floated element |     main content here
    |stops           |     main content here
    |here            |     main content here
main content here
main content here

http://jsfiddle.net/my5Aj/

How can it be fixed?


Just put the right content in its own div, set its width and float: right;.


Give the main content a margin-left of the floated elements width.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜