Update app.py
Browse files
app.py
CHANGED
@@ -9,23 +9,28 @@ st.set_page_config(
|
|
9 |
layout="wide" # Optional: Use wide layout
|
10 |
)
|
11 |
|
12 |
-
# --- Custom CSS
|
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 !important; /* Force sticky positioning */
|
19 |
top: 0px !important; /* Force sticking to the top edge */
|
20 |
z-index: 999 !important; /* Force a high z-index */
|
21 |
-
background-color: rgb(255, 255, 255) !important; /* Force background color */
|
22 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow
|
23 |
-
/* Ensure no conflicting height/overflow properties */
|
24 |
height: auto !important; /* Force height to adjust */
|
25 |
-
overflow: visible !important; /*
|
26 |
}
|
27 |
|
28 |
-
/* Add padding to the main content area to prevent it from starting behind the
|
29 |
/* This targets the main container div where your app content and pages are rendered */
|
30 |
/* Adjust this value based on the header's actual height after inspecting the deployed app */
|
31 |
[data-testid="stAppViewContainer"] {
|
@@ -42,14 +47,6 @@ st.markdown("""
|
|
42 |
padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
|
43 |
}
|
44 |
|
45 |
-
/* Ignore the data-testid="stMain" observation for the header stickiness,
|
46 |
-
as stMain is typically the main content area, not the header bar with status.
|
47 |
-
The sticky CSS should target the <header> tag.
|
48 |
-
If you confirmed the element you want sticky is truly not the <header> tag,
|
49 |
-
then the CSS selector above needs to be changed to target that specific element
|
50 |
-
and its parents examined for overflow/transform issues.
|
51 |
-
*/
|
52 |
-
|
53 |
</style>
|
54 |
""", unsafe_allow_html=True)
|
55 |
|
|
|
9 |
layout="wide" # Optional: Use wide layout
|
10 |
)
|
11 |
|
12 |
+
# --- Custom CSS to Fix Parent Overflow and Make Header Sticky ---
|
13 |
st.markdown("""
|
14 |
<style>
|
15 |
+
/* Target the main app container and ensure its overflow is visible */
|
16 |
+
/* This is crucial for sticky positioning of elements inside it relative to the viewport */
|
17 |
+
[data-testid="stApp"] {
|
18 |
+
overflow: visible !important; /* Force overflow to be visible */
|
19 |
+
}
|
20 |
+
|
21 |
/* Target the default Streamlit header element */
|
22 |
/* This is typically the <header> tag containing the title, menu, and status */
|
23 |
header {
|
24 |
position: sticky !important; /* Force sticky positioning */
|
25 |
top: 0px !important; /* Force sticking to the top edge */
|
26 |
z-index: 999 !important; /* Force a high z-index */
|
27 |
+
background-color: rgb(255, 255, 255) !important; /* Force background color (white or match Streamlit's default) */
|
28 |
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow */
|
|
|
29 |
height: auto !important; /* Force height to adjust */
|
30 |
+
/* overflow: visible !important; /* This might also be needed on the header itself */
|
31 |
}
|
32 |
|
33 |
+
/* Add padding to the main content area to prevent it from starting behind the sticky header */
|
34 |
/* This targets the main container div where your app content and pages are rendered */
|
35 |
/* Adjust this value based on the header's actual height after inspecting the deployed app */
|
36 |
[data-testid="stAppViewContainer"] {
|
|
|
47 |
padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
</style>
|
51 |
""", unsafe_allow_html=True)
|
52 |
|