import streamlit as st import time # Inspect the header element, go to the "Computed" tab in styles, and find its height. HEADER_HEIGHT = "61px" # EXAMPLE: Adjust this (e.g., "56px", "4rem") HEADER_SELECTOR = 'header[data-testid="stHeader"]' # ---- SELECTOR FOR THE MAIN CONTENT AREA THAT NEEDS PADDING ---- # This targets the first direct div child of the stAppViewContainer, # which often holds the main scrollable content. #MAIN_CONTENT_SELECTOR = 'section[data-testid="stApp"]' MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"]' #MAIN_CONTENT_SELECTOR = 'section[data-testid="stMain"] > div:nth-child(1)' #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] > div:nth-child(1)' # Alternative if the above doesn't work or if your content is further nested: #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .main-content-wrapper-class' # Or, very commonly, Streamlit wraps main content in a div with class "block-container": #MAIN_CONTENT_SELECTOR = 'section[data-testid="stAppViewContainer"] .block-container' #MAIN_CONTENT_SELECTOR = '.main .block-container' # A more general selector for block-container custom_css = f""" """ # Inject CSS as early as possible in your app st.markdown(custom_css, unsafe_allow_html=True) # --- Your Streamlit App --- #st.logo(image="images/menu_book_60dp_75FBFD.png") st.title("SBS V2.0 mapper") st.sidebar.header("SBS V2.0 mapper") st.sidebar.write("work in progress.") st.sidebar.text("Demo by JA-RAD") st.header("Main Content Section") st.write(f"The header should be sticky. This content section has a top padding of approximately {HEADER_HEIGHT} to compensate for the header.") st.info(f"Header Selector Used: `{HEADER_SELECTOR}`") st.info(f"Main Content Selector Used: `{MAIN_CONTENT_SELECTOR}`") # --- PAGE SETUP --- type_text_page = st.Page( page="pages/type_text.py", title="DEMO (work in progress)", icon=":material/keyboard:", default=True,) # --- NAVIGATION SETUP --- pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS #pg = st.navigation({"Chapter_Index": [start_page], "Demo": [type_text_page, upload_file_page], "About": [about_page]}) # WITH SECTIONS pg.run()