lets say I have a normal text in a paragraph (<p>...</p>). Now I want to place a box with for example ads or additional information somewhere in the text to the right or left. It should NOT be above or below the text, the text should align itself around the box.
假设我在段落中有一个普通文本(
... )。现在我想在右侧或左侧的文本中的某处放置一个带有例如广告或附加信息的框。它不应高于或低于文本,文本应在框周围对齐。
How would I do this? I tried with span and div but failed so far. Ideas?
我该怎么办?我尝试使用span和div但到目前为止失败了。想法?
Thanks :-)
谢谢 :-)
2 个解决方案
#1
2
Use <div>
with float
CSS property.
使用带有float CSS属性的
<p>
<div style="background-color: red; height: 100px; width: 100px; float: right"></div>
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
</p>
#2
1
This isn't possible with HTML alone but with CSS you can float a child element to one side.
单独使用HTML是不可能的,但使用CSS可以将子元素浮动到一边。
http://jsfiddle.net/9A2vB/
#1
2
Use <div>
with float
CSS property.
使用带有float CSS属性的
<p>
<div style="background-color: red; height: 100px; width: 100px; float: right"></div>
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
XXXXXX XXXXXX XXXXXX XXXXXX XXXXXX
</p>
#2
1
This isn't possible with HTML alone but with CSS you can float a child element to one side.
单独使用HTML是不可能的,但使用CSS可以将子元素浮动到一边。
http://jsfiddle.net/9A2vB/