我希望将滚动条添加到 Dash 应用程序的侧栏面板 - 请参阅此应用程序作为示例。当内容跑出页面时,我可以让滚动条动态显示,但我似乎可以让主页 div 显示在侧边栏 div 右侧的唯一方法是设置 CSS style "position": "fixed"。但是,即使滚动条可用,该设置也会将内容固定在适当的位置。
这是代码:
import dash
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])
# the style arguments for the sidebar. We use position:fixed and a fixed width
SIDEBAR_STYLE = {
"position": "fixed",
"top": 0,
"left": 0,
"bottom": 0,
"width": "16rem",
"padding": "2rem 1rem",
"background-color": "#f8f9fa",
}
# the styles for the main content position …Run Code Online (Sandbox Code Playgroud)