【问题标题】:Move dynamic text box higher, if it wraps, to stop it from covering up the next text box below or将动态文本框向上移动(如果它换行),以阻止它覆盖下面的下一个文本框或
【发布时间】:2017-11-17 11:42:19
【问题描述】:

我有两个动态文本框放在一起。有时第一个文本框会换成两行,这意味着它会覆盖第二个文本框。我怎样才能检测到第一个文本框已经换成两行,如果是这样,将文本框移高一点(我不能移动第二个文本框,第一个文本框上面有一些可以使用的空间)。

谢谢

【问题讨论】:

  • 发布您的代码。

标签: javascript html5-canvas createjs easeljs


【解决方案1】:

您可以获得文本的边界。

var bounds = text1.getBounds();
// Note, add in bounds.y to account for the text baseline
text2.y = text1.y + bounds.y + bounds.height + paddingValue;

Bounds 相当准确,但并不完美。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-23
    • 1970-01-01
    • 2020-12-23
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-25
    相关资源
    最近更新 更多