【问题标题】:How do I get text to flow around a div above and below?如何让文本在上方和下方的 div 周围流动?
【发布时间】:2012-09-04 19:16:39
【问题描述】:

我基本上想要这个:

-----------------------------------------------------------------
|                                                               |
| Text Text Text Text Text Text Text Text Text Text Text Text   |
| Text Text Text Text Text Text Text Text Text Text Text Text   |
|---------------------| Text Text Text Text Text Text Text Text |
|                     | Text Text Text Text Text Text Text Text |
|     DIV             | Text Text Text Text Text Text Text Text |
|                     | Text Text Text Text Text Text Text Text |
|---------------------| Text Text Text Text Text Text Text Text |
| Text Text Text Text Text Text Text Text Text Text Text Text   |
| Text Text Text Text Text Text Text Text Text Text Text Text   |
-----------------------------------------------------------------

将 div 向左浮动并让文本在其下方流动很容易,但我也需要文本从其上方的左侧流动。

这是我目前所拥有的,我只是不知道从哪里开始:http://jsfiddle.net/x7HFZ/2/

另外,文本将是动态的,我需要固定 div 的位置。

【问题讨论】:

  • jsFiddle 有一个 CSS 部分。您应该使用它而不是内联样式以便于编辑。
  • 在lipsum文本中向下移动#panel2ColLeft。
  • @sachleen 不仅是 jsFiddle。您也可以在现实生活中的网页中使用它。 ;-)
  • 请放心,现实生活中的页面将使用样式表,当我遇到这样的布局难题时,内嵌样式只会帮助我解决问题。

标签: html css styles


【解决方案1】:

将div放在文本中间:

http://jsfiddle.net/GolezTrol/x7HFZ/14/

【讨论】:

  • 假设文本是动态的,知道如何“修复” div 的位置吗?
  • 你不能,除非你想办法把那个html放在中间的某个地方。
  • @invertedSpear 即使文本是动态的,将其插入 HTML 中的特定位置也不会影响 divs 的位置。
  • @Abody97 是的,因为要获得所需的结果,div 必须位于文本之间,如果您必须使用来自 CMS 或任何类似来源的动态文本,这会更难。
  • 是的,不是我的设计部门想要的答案,但只能做这么多。我可以通过计算字符来推测位置,因为它看起来只会浮动到它插入的任何行的左侧,但是它可以向上或向下移动一行的想法并不吸引人。这就是生活。谢谢 GolezTrol。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-27
  • 2015-04-08
  • 1970-01-01
  • 1970-01-01
  • 2018-09-01
  • 1970-01-01
相关资源
最近更新 更多