Update app.py
Browse files
app.py
CHANGED
@@ -9,28 +9,27 @@ st.set_page_config(
|
|
9 |
layout="wide" # Optional: Use wide layout
|
10 |
)
|
11 |
|
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; /*
|
19 |
-
top: 0px; /*
|
20 |
-
z-index: 999; /*
|
21 |
-
background-color: rgb(255, 255, 255); /*
|
22 |
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Add shadow
|
23 |
-
/* Ensure no conflicting height/overflow properties
|
24 |
-
height: auto; /*
|
25 |
-
overflow: visible; /*
|
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 |
-
/*
|
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
|
34 |
}
|
35 |
|
36 |
/* Adjust padding for the sidebar content as well */
|
@@ -39,23 +38,16 @@ st.markdown("""
|
|
39 |
}
|
40 |
|
41 |
/* Ensure the main content block within the container also has correct top padding */
|
42 |
-
/* This might be necessary for correct spacing below the header */
|
43 |
.main .block-container {
|
44 |
padding-top: 1rem; /* Keep or adjust default Streamlit content padding */
|
45 |
}
|
46 |
|
47 |
-
/*
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
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>
|
|
|
9 |
layout="wide" # Optional: Use wide layout
|
10 |
)
|
11 |
|
12 |
+
# --- Custom CSS for Sticky Default Header (with !important) ---
|
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 (usually doesn't need !important) */
|
23 |
+
/* Ensure no conflicting height/overflow properties */
|
24 |
+
height: auto !important; /* Force height to adjust */
|
25 |
+
overflow: visible !important; /* Force overflow visible */
|
26 |
}
|
27 |
|
28 |
+
/* Add padding to the main content area to prevent it from starting behind the fixed header */
|
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"] {
|
32 |
+
padding-top: 60px; /* Estimate header height (~60px). Adjust if needed. */
|
33 |
}
|
34 |
|
35 |
/* Adjust padding for the sidebar content as well */
|
|
|
38 |
}
|
39 |
|
40 |
/* Ensure the main content block within the container also has correct top padding */
|
|
|
41 |
.main .block-container {
|
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>
|