2010-06-22 46 views
1

我有一個跨度,它位於固定寬度的div內。範圍包含可能換行到多行的文本。右對齊span元素內的第一條線

我的問題是,我希望第一行文本是右對齊的,後續行(由換行引起)自動左對齊第一行。

即,

 
    This is what I want to 
    happen after a word 
    wrap 

    This is what I do NOT 
      want to happen 

回答

2

您span和div之間,添加另一個DIV與浮動:正確的。

如:

<div style="width:200px"> 
    <div style="float:right"> 
    <span>This is what I want to happen after a word wrap</span> 
    </div> 
</div> 

不要忘了清除浮動。

+0

謝謝,這是做的伎倆。 – Einar 2010-06-24 10:21:47