georad commited on
Commit
71977e3
·
verified ·
1 Parent(s): 0e34d54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -29
app.py CHANGED
@@ -1,46 +1,59 @@
1
  import streamlit as st
2
 
3
- # Reset any previous custom styles
4
  st.set_page_config(page_title="My App", layout="wide")
5
 
6
- # Your app content starts here
7
- st.title("My App Title")
8
-
9
- # Create a custom header with container
10
- header = st.container()
11
- with header:
12
- col1, col2 = st.columns([3, 1])
13
- with col1:
14
- st.subheader("Custom Sticky Navigation")
15
- with col2:
16
- st.button("Button 1")
17
-
18
- # Add minimal CSS that won't interfere with status toolbar
19
  st.markdown("""
20
  <style>
21
- /* Target only our specific header container */
22
- [data-testid="stContainer"]:first-child {
23
- position: -webkit-sticky;
24
- position: sticky;
25
- top: 0px;
26
  background-color: #f0f5f5;
27
- padding: 1rem;
28
- z-index: 50;
29
  border-bottom: 1px solid #ddd;
 
 
 
30
  }
31
-
32
- /* Ensure this doesn't affect other containers */
33
- [data-testid="stContainer"]:not(:first-child) {
34
- margin-top: 1rem;
 
 
 
35
  }
36
  </style>
 
 
 
 
 
 
 
 
 
 
37
  """, unsafe_allow_html=True)
38
 
39
- # Main content area
40
- st.write("Main content starts here")
 
 
 
 
 
 
 
 
 
 
41
 
42
- # Add sample content to demonstrate scrolling
43
- for i in range(30):
44
  st.write(f"Content line {i}")
45
 
46
 
 
1
  import streamlit as st
2
 
3
+ # Set page config
4
  st.set_page_config(page_title="My App", layout="wide")
5
 
6
+ # Minimal CSS that shouldn't interfere with status toolbar
 
 
 
 
 
 
 
 
 
 
 
 
7
  st.markdown("""
8
  <style>
9
+ .fixed-nav {
10
+ position: fixed;
11
+ top: 0;
12
+ left: 0;
13
+ width: 100%;
14
  background-color: #f0f5f5;
15
+ padding: 10px;
16
+ z-index: 999;
17
  border-bottom: 1px solid #ddd;
18
+ display: flex;
19
+ justify-content: space-between;
20
+ align-items: center;
21
  }
22
+ .main-content {
23
+ margin-top: 60px;
24
+ }
25
+ /* Don't hide status toolbar */
26
+ [data-testid="stStatusWidget"] {
27
+ visibility: visible !important;
28
+ z-index: 1000;
29
  }
30
  </style>
31
+
32
+ <div class="fixed-nav">
33
+ <h2>App Navigation</h2>
34
+ <div>
35
+ <button onclick="window.location.href='#section1'">Section 1</button>
36
+ <button onclick="window.location.href='#section2'">Section 2</button>
37
+ </div>
38
+ </div>
39
+ <div class="main-content">
40
+ </div>
41
  """, unsafe_allow_html=True)
42
 
43
+ # Main app title and content
44
+ st.title("My App with Navigation")
45
+
46
+ # Add sample content
47
+ st.header("Section 1", anchor="section1")
48
+ st.write("This is section 1 content")
49
+
50
+ for i in range(10):
51
+ st.write(f"Content line {i}")
52
+
53
+ st.header("Section 2", anchor="section2")
54
+ st.write("This is section 2 content")
55
 
56
+ for i in range(10):
 
57
  st.write(f"Content line {i}")
58
 
59