Update app.py
Browse files
app.py
CHANGED
@@ -12,21 +12,25 @@ st.set_page_config(
|
|
12 |
# --- Custom CSS for Sticky Default Header ---
|
13 |
st.markdown("""
|
14 |
<style>
|
15 |
-
/*
|
|
|
16 |
header {
|
17 |
position: sticky; /* Use sticky positioning */
|
18 |
top: 0px; /* Stick to the top edge */
|
19 |
z-index: 999; /* Ensure the header is always on top */
|
20 |
background-color: rgb(255, 255, 255); /* Use white background or match Streamlit's default header color */
|
21 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow for better visibility */
|
22 |
-
/*
|
|
|
|
|
23 |
}
|
24 |
|
25 |
/* Add padding to the main content area to prevent it from starting behind the sticky header */
|
26 |
/* This targets the main container div where your app content and pages are rendered */
|
27 |
/* The exact value might need slight adjustment based on the header's actual height */
|
|
|
28 |
[data-testid="stAppViewContainer"] {
|
29 |
-
padding-top: 60px; /* Estimate header height (~60px). Adjust if needed. */
|
30 |
}
|
31 |
|
32 |
/* Adjust padding for the sidebar content as well */
|
@@ -40,6 +44,20 @@ st.markdown("""
|
|
40 |
padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
|
41 |
}
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
</style>
|
44 |
""", unsafe_allow_html=True)
|
45 |
|
|
|
12 |
# --- Custom CSS for Sticky Default Header ---
|
13 |
st.markdown("""
|
14 |
<style>
|
15 |
+
/* Target the default Streamlit header element */
|
16 |
+
/* This is typically the <header> tag containing the title, menu, and status */
|
17 |
header {
|
18 |
position: sticky; /* Use sticky positioning */
|
19 |
top: 0px; /* Stick to the top edge */
|
20 |
z-index: 999; /* Ensure the header is always on top */
|
21 |
background-color: rgb(255, 255, 255); /* Use white background or match Streamlit's default header color */
|
22 |
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow for better visibility */
|
23 |
+
/* Ensure no conflicting height/overflow properties that might break sticky */
|
24 |
+
height: auto; /* Allow height to adjust based on content */
|
25 |
+
overflow: visible; /* Prevent content inside header from being clipped */
|
26 |
}
|
27 |
|
28 |
/* Add padding to the main content area to prevent it from starting behind the sticky header */
|
29 |
/* This targets the main container div where your app content and pages are rendered */
|
30 |
/* The exact value might need slight adjustment based on the header's actual height */
|
31 |
+
/* Inspect the deployed app to confirm the header height and adjust padding-top accordingly */
|
32 |
[data-testid="stAppViewContainer"] {
|
33 |
+
padding-top: 60px; /* Estimate header height (~60px). Adjust if needed after inspection. */
|
34 |
}
|
35 |
|
36 |
/* Adjust padding for the sidebar content as well */
|
|
|
44 |
padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
|
45 |
}
|
46 |
|
47 |
+
/* If the above 'header' sticky rule still doesn't work for the main scrollbar
|
48 |
+
after adjusting padding-top, it strongly indicates a parent element issue.
|
49 |
+
You would need to use browser dev tools to find which parent is breaking it
|
50 |
+
and potentially try applying sticky to that parent, but that is more complex.
|
51 |
+
For example, if a div wrapping the header and main content had overflow: auto:
|
52 |
+
div[data-testid="some-parent-container"] {
|
53 |
+
position: sticky;
|
54 |
+
top: 0;
|
55 |
+
z-index: 998; // Lower z-index than the header
|
56 |
+
background: white;
|
57 |
+
}
|
58 |
+
This is hypothetical and requires DOM inspection.
|
59 |
+
*/
|
60 |
+
|
61 |
</style>
|
62 |
""", unsafe_allow_html=True)
|
63 |
|