【发布时间】:2021-12-13 13:28:56
【问题描述】:
对于我的 Dash 应用程序,我想创建一个导航栏,其中包含指向不同页面的链接以及其他内容,例如当前登录的用户,以及徽标和内容。
但是,很遗憾,我无法使用页面(如 dbc 中的“导航栏”示例),因为 WebApp 必须作为单个 URL 应用程序托管在另一个工具中。我唯一的选择是使用dcc.Tabs。 但是,在我看来,dcc.Tabs 在选项卡后面强制换行。我尝试了不同的方法来防止这种情况发生,但似乎没有任何效果。到目前为止我得到的最好的是下面的例子。如何使文本与 Tabs 元素位于同一行?
tabs_styles = {
'height': '44px', "width": "49%", "display":"inline-block"
}
app.layout = html.Div(children=[
html.Div(children=[
dcc.Tabs(id="tabs-styled-with-inline", value='tab-1', children=[
dcc.Tab(label='Page1', value='tab-1', style=tab_style, selected_style=tab_selected_style),
dcc.Tab(label='Page2', value='tab-2', style=tab_style, selected_style=tab_selected_style),
], style=tabs_styles)]),
html.Span(children=[
" Logged in as ",
html.Strong(id="username")
], style = tabs_styles),
html.Div(children=[
# Distance to header:
html.Hr(),
html.Div(id='tabs-content-inline')
])
])
【问题讨论】:
标签: python css plotly-dash