如何使文本适合 Plotly 网络应用程序中的按钮宽度?
How to make text fit to the button width in Plotly web app?
我正在制作一个带有 plotly dash 的网络应用程序。当然有回调,然后def,最后result输出到一个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
children在这个Div
html.Div([
html.Button(id='prediction-content'),
]),
现在我的问题是,当我缩小浏览器时,按钮是有响应的(因为它的 CSS 是宽度:100%),但按钮上的文本不是。
那么如何换行文本以适合按钮?就像句子的其余部分转到下一行,而不是被削减?
谢谢!
顺便说一句,我在谷歌上搜索了很多,但找不到解决方案。找到一个相似的 post,
Make button width fit to the text,不过好像不行。
我终于修复了它,在我的自定义 CSS 中,我添加了:
Height: 100%;
white-space: normal
现在,显示溢出的文本。
我正在制作一个带有 plotly dash 的网络应用程序。当然有回调,然后def,最后result输出到一个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
children在这个Div
html.Div([
html.Button(id='prediction-content'),
]),
现在我的问题是,当我缩小浏览器时,按钮是有响应的(因为它的 CSS 是宽度:100%),但按钮上的文本不是。
那么如何换行文本以适合按钮?就像句子的其余部分转到下一行,而不是被削减?
谢谢!
顺便说一句,我在谷歌上搜索了很多,但找不到解决方案。找到一个相似的 post, Make button width fit to the text,不过好像不行。
我终于修复了它,在我的自定义 CSS 中,我添加了:
Height: 100%;
white-space: normal
现在,显示溢出的文本。