如何使工具提示内容出现在一行中?

时间:2013-04-26 08:01:44

标签: javascript jquery css

我有一个工具提示,应用了title属性:

<img src="myGif.gif" border="0"  class="tooltip" alt="Help"
title="This is a world of mad people who don't believe in what they are doing and as such they are extremely risky and will lead to the destruction of the society as we call it"/>

问题是,我希望内容出现在一行中,但它在IE和Mozilla中分崩离析。

在ie(7和8)中,内容将以三行显示:

This is a world of mad people who don't believe in what they are doing
and as such they are extremely risky and will lead to the 
destruction of the society as we call it

在Mozilla中,它会像这样呈现:

This is a world of mad people who don't believe in what they are doing and as such they are
extremely risky and will lead to the destruction of the society as we call it

但我希望将内容呈现在一行中。

所以我需要使用javascript或CSS或jquery来渲染它。但是,直到现在我还是无法这样做。

1 个答案:

答案 0 :(得分:0)

您应该在某处定义类似工具提示样式的tooltip.css文件。因此,请将默认工具提示css设置为:white-space:nowrap;。这将迫使一行上的所有内容,但它可能导致文本运行元素,因此您可能还必须调整工具提示的宽度(如果您的网站上的其他地方有工具提示,这是一个特殊情况,一个更智能的解决方案是为这种情况创建自定义css,并使用它并保留默认的css,因为它适用于所有其他情况。)