Nav-Bar disappears using fixed-top argument

Python==3.9.0
streamlit==1.11.0

Streamlit header element z-index value is 999990,so it will cover your navbar,set it to 0.

import streamlit as st

st.set_page_config(layout="wide")

col1, col2 = st.columns((2, 3))

st.markdown(
    '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">',
    unsafe_allow_html=True)

nav_bar = """
<nav class="navbar fixed-top navbar-expand-lg bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Eventer</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">About Us</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Contact</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Join</a>
        </li>
      </ul>
    </div>
  </div>
</nav>
"""
st.markdown(nav_bar, unsafe_allow_html=True)

# Short description of the app
st.markdown("<h2 style='text-align: center; color: Black;'>Some title</h2>", unsafe_allow_html=True)
# some body
st.write("""

	This is some sample text.
	""")

# set streamlit header z-index
st.markdown('''
<style>
.stApp header {
    z-index: 0;
}
</style>
''', unsafe_allow_html=True)

2 Likes