【问题标题】:How to make text fit to the button width in Plotly web app?如何使文本适合 Plotly Web 应用程序中的按钮宽度?
【发布时间】:2020-12-02 22:06:13
【问题描述】:

我正在制作一个带有 plotly dash 的网络应用程序。当然还有回调,然后def,最后将结果输出给一个children。

回调如下,

@app.callback(
    Output('prediction-content', 'children'),
    [Input('input', 'value')]

def 的输出是一条长消息,带有模型预测,如下所示:

def predict(input):

    function(input)
    results = f'xxxxxx ${pred:,.0f} xxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxx'

    return results

孩子们在这个Div中

html.Div([
                html.Button(id='prediction-content'),
            ]),

现在我的问题是,当我缩小浏览器时,按钮是响应式的(因为它的 CSS 是 width: 100%),但按钮上的文本不是。

那么如何包装文本以适应按钮?就像句子的其余部分转到下一行,而不是被削减?

谢谢!

顺便说一句,我用谷歌搜索了很多,但找不到解决方案。找到一个类似的帖子, Make button width fit to the text,不过好像不行。

【问题讨论】:

  • 谢谢,我实际上已经尝试过“空白:正常”,以及该页面上的其他建议答案。这些语法确实有助于将句子分解为单词,但溢出的文本仍然不会转到下一行。

标签: html css plotly plotly-dash plotly-python


【解决方案1】:

我终于修好了,在我的自定义 CSS 中,我补充说:

Height: 100%;
white-space: normal

现在,溢出的文本显示出来了。

【讨论】:

    猜你喜欢
    • 2015-02-27
    • 2014-05-07
    • 2020-05-29
    • 2017-07-21
    • 2021-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多