简体   繁体   English

HTML / CSS:元素一直浮动

[英]HTML/CSS: Having floated element all the way

I want to keep my floated element called leftPanel follow all the time. 我想一直保持我的浮动元素leftPanel的跟随。

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
|                |     main 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/ http://jsfiddle.net/my5Aj/

How can it be fixed? 如何解决?

Just put the right content in its own div , set its width and float: right; 只需将正确的内容放在其自己的div ,设置其widthfloat: right; .

给主要内容一个浮动元素宽度的左边距。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM