I have a navigation bar on top of my app which I would like to always keep visible
I do the trick by embedding my Html.A in an Html,Div with a style attribute position : fixed
This works fine
The navbar stays visible on the top f my page when I scroll down
but if I have a graph in my page and I scroll down then the graph will hide my navabr even it seems that its position is fixed
please check my code snippet below , I also include my css external sheet`
import dash
import dash_html_components as html
import dash_core_components as dccexternal_stylesheets = [â/assets/test.cssâ]
app = dash.Dash(name,external_stylesheets=external_stylesheets)app.layout = html.Div(children = [html.Div(children =[ html.Ul(children= [
html.Li(html.A(âHomeâ,className=âactiveâ ,href =â#homeâ)),
html.Li(html.A(âNewsâ, href =â#newsâ)),
html.Li(html.A(âHomeâ, href =â#contactâ)),
html.Li(html.A(âHomeâ, href =â#aboutâ)),
])],style={âbackground-imageâ:âurl(â/assets/diginex_inline_logo.svgâ)â,
âbackground-repeatâ: âno-repeatâ,âbackground-positionâ: âright topâ,
âbackground-sizeâ: â300px 30pxâ,âheightâ:â5%â,âpositionâ:âfixedâ,
âtopâ:â0â,âborderâ:â3px solidâ,âwidthâ:â100%â}),
html.Div(style={âpaddingâ:â20pxâ,âmargin-topâ:â30pxâ,âbackground-colorâ:â#FFFFFFâ,âheightâ:â1500pxâ},children=[
#html.Div(dcc.Graph(style={âheightâ:â500pxâ})),
html.H1(âFixed Top Navigation Barâ),
html.H2(âScroll the page to see the effectâ),
html.H2(âThe Navigation bar will stay at the top of the page while scrollingâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
html.P(âSome text some text some text some textâŚâ),
])
])if name == âmainâ:
app.run_server(debug=True,port =8051)
you will see the difference in befaviour after you comment out the line html.Div(dcc.Graph(style={âheightâ:â500pxâ}
this is my css file test.css referenced as external_sheets
body {margin:0;}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top:0;
width: 50%;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover:not(.active) {
background-color: #111;
}
.active {
background-color: #4CAF50;
}
What am I ding wrong? Please help if you have experienced omething similar