georad commited on
Commit
b076b9c
·
verified ·
1 Parent(s): 85a1488

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -16,9 +16,42 @@ def setup_page():
16
  st.write(df_chapters.head())
17
 
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
 
22
  if __name__ == "__main__":
 
23
  st.set_page_config(page_title="Sticky Header test", layout="wide")
24
  setup_page()
 
16
  st.write(df_chapters.head())
17
 
18
 
19
+ custom_css = f"""
20
+ <style>
21
+ /* Making the Streamlit header sticky */
22
+ {HEADER_SELECTOR} {{
23
+ position: -webkit-sticky !important; /* For Safari */
24
+ position: sticky !important;
25
+ top: 0 !important;
26
+ z-index: 9999 !important; /* Very high z-index */
27
+ background-color: #90EE90 !important; /* Or your app's header background color */
28
+ /* Add a subtle shadow to make it feel more distinct when content scrolls under */
29
+ /* box-shadow: 0 2px 4px -1px rgba(0,0,0,0.1); */
30
+ /*.reportview-container .main .block-container{{ */
31
+ /* padding-top: 0rem; */
32
+ /* }} */
33
+ }}
34
 
35
+ /* Adding padding to the main content area to prevent overlap with the sticky header */
36
+ {MAIN_CONTENT_SELECTOR} {{
37
+ padding-top: 10px !important; /* {HEADER_HEIGHT} !important; */
38
+ /* background-color: yellow !important; */
39
+ /* border-style: solid !important; */
40
+ /* border-color: red !important; */
41
+ }}
42
+
43
+ /* Optional: If your app is set to wide mode and the header isn't spanning full width */
44
+ /* This might be needed if the sticky positioning affects its width calculation. */
45
+ /*
46
+ #{HEADER_SELECTOR} {{
47
+ # width: 100% !important;
48
+ #}}
49
+ #*/
50
+ </style>
51
+ """
52
 
53
 
54
  if __name__ == "__main__":
55
+ st.markdown(custom_css, unsafe_allow_html=True)
56
  st.set_page_config(page_title="Sticky Header test", layout="wide")
57
  setup_page()