css - 如何使用 dash-bootstrap 将标题文本垂直和水平居中
问题描述
我正在为我的 Web 应用程序布局使用Bootstrap dash布局。但是,与其将文本放在页面顶部,我希望文本位于红色区域。我怎样才能实现它?
我试过使用"align":"center" and "justify":"center"
但没有任何帮助
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash
body = dbc.Container([
dbc.Row(
[
html.H1("test")
], justify="center", align="center"
)
]
)
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SUPERHERO])
app.layout = html.Div([body])
if __name__ == "__main__":
app.run_server(debug=True)
了解使用flask-bootstrap有一些解决方法,但我如何使用 dash-plotly-booststrap 做同样的事情?
解决方案
在通过开发者的 github 搜索后,我发现了这个已关闭的问题,原来您可以使用 Container 的style
参数设置破折号行的高度,并使用className="h-50"
. 所以解决方案看起来像这样:
import dash_bootstrap_components as dbc
import dash_html_components as html
import dash
body = dbc.Container([
dbc.Row(
[
html.H1("test")
], justify="center", align="center", className="h-50"
)
],style={"height": "100vh"}
)
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.SUPERHERO])
app.layout = html.Div([body])
if __name__ == "__main__":
app.run_server(debug=True)
推荐阅读
- python - 如何根据另一列填充 Pandas 中的数字缺失值
- c++ - 0x%08lx 用于 cout 的 printf 语句中的格式说明符
- azure - 如何在 Azure DevOps 中编译 .NET(控制台应用程序)并生成 exe
- ios - 找不到框架 Crashlytics
- c - 理解错误共享和内存对齐
- excel - Excel合并B列中具有相同A列的行的值
- python - 带有身份验证的 Python 请求 (API_KEY)
- bash - 如果 bash 脚本由于 set -e 而终止,我如何显示特定命令的错误消息
- typescript - 通过 Lambda 禁用 cognito 用户
- angular - 角度引导开关按钮加载太晚