georad commited on
Commit
cbb5f8e
·
verified ·
1 Parent(s): 561774a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -48
app.py CHANGED
@@ -1,71 +1,72 @@
1
  import streamlit as st
2
 
3
  # Set page config
4
- st.set_page_config(page_title="Hybrid Solution", layout="wide")
5
-
6
- # Create a custom HTML component just for the navigation
7
- nav_html = """
8
- <div style="position:fixed; top:0; left:0; width:100%; background-color:#262730; color:white; padding:10px; z-index:9999; text-align:center;">
9
- <h3 style="display:inline-block; margin:0 20px;">My App Navigation</h3>
10
- <a href="#section1" style="color:white; margin:0 10px;">Section 1</a>
11
- <a href="#section2" style="color:white; margin:0 10px;">Section 2</a>
12
- <a href="#section3" style="color:white; margin:0 10px;">Section 3</a>
13
- </div>
14
- <div style="height:50px;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  """
16
 
17
- # Inject the navigation HTML
18
- st.components.v1.html(nav_html, height=50)
 
 
 
19
 
20
- # Regular Streamlit content with anchors
21
  st.title("My Application")
22
 
23
  st.header("Section 1", anchor="section1")
24
  st.write("This is section 1 content")
25
- for i in range(5):
26
  st.write(f"Content line {i}")
27
 
28
  st.header("Section 2", anchor="section2")
29
  st.write("This is section 2 content")
30
- for i in range(5):
31
  st.write(f"Content line {i}")
32
 
33
  st.header("Section 3", anchor="section3")
34
  st.write("This is section 3 content")
35
- for i in range(5):
36
- st.write(f"Content line {i}")
37
-
38
- st.header("Section 4", anchor="section4")
39
- st.write("This is section 1 content")
40
- for i in range(5):
41
- st.write(f"Content line {i}")
42
-
43
- st.header("Section 5", anchor="section5")
44
- st.write("This is section 2 content")
45
- for i in range(5):
46
- st.write(f"Content line {i}")
47
-
48
- st.header("Section 6", anchor="section6")
49
- st.write("This is section 3 content")
50
- for i in range(5):
51
  st.write(f"Content line {i}")
52
 
53
- st.header("Section 7", anchor="section7")
54
- st.write("This is section 1 content")
55
- for i in range(5):
56
- st.write(f"Content line {i}")
57
-
58
- st.header("Section 8", anchor="section8")
59
- st.write("This is section 2 content")
60
- for i in range(5):
61
- st.write(f"Content line {i}")
62
-
63
- st.header("Section 9", anchor="section9")
64
- st.write("This is section 3 content")
65
- for i in range(5):
66
- st.write(f"Content line {i}")
67
-
68
-
69
 
70
  # --- SHARED ON ALL PAGES ---
71
  st.logo(image="images/menu_book_60dp_75FBFD.png")
 
1
  import streamlit as st
2
 
3
  # Set page config
4
+ st.set_page_config(page_title="Experimental Solution", layout="wide")
5
+
6
+ # Use JavaScript to create and maintain a sticky header
7
+ js_code = """
8
+ <script>
9
+ // Function to create sticky header
10
+ function createStickyHeader() {
11
+ // Create header element
12
+ const header = document.createElement('div');
13
+ header.style.position = 'fixed';
14
+ header.style.top = '0';
15
+ header.style.left = '0';
16
+ header.style.width = '100%';
17
+ header.style.backgroundColor = '#262730';
18
+ header.style.color = 'white';
19
+ header.style.padding = '10px';
20
+ header.style.zIndex = '9999';
21
+ header.style.textAlign = 'center';
22
+ header.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
23
+
24
+ // Add content to header
25
+ header.innerHTML = `
26
+ <h3 style="display:inline-block; margin:0 20px;">My App Navigation</h3>
27
+ <a href="#section1" style="color:white; margin:0 10px;">Section 1</a>
28
+ <a href="#section2" style="color:white; margin:0 10px;">Section 2</a>
29
+ <a href="#section3" style="color:white; margin:0 10px;">Section 3</a>
30
+ `;
31
+
32
+ // Append header to body
33
+ document.body.appendChild(header);
34
+
35
+ // Add padding to top of body to prevent content from being hidden
36
+ document.body.style.paddingTop = (header.offsetHeight + 10) + 'px';
37
+ }
38
+
39
+ // Initialize when DOM is loaded
40
+ document.addEventListener('DOMContentLoaded', createStickyHeader);
41
+ // Backup in case the first attempt fails
42
+ setTimeout(createStickyHeader, 1000);
43
+ </script>
44
  """
45
 
46
+ # Inject the JavaScript
47
+ st.components.v1.html(js_code, height=0)
48
+
49
+ # Add a small spacer for header
50
+ st.markdown("<div style='height:60px;'></div>", unsafe_allow_html=True)
51
 
52
+ # Regular Streamlit content
53
  st.title("My Application")
54
 
55
  st.header("Section 1", anchor="section1")
56
  st.write("This is section 1 content")
57
+ for i in range(10):
58
  st.write(f"Content line {i}")
59
 
60
  st.header("Section 2", anchor="section2")
61
  st.write("This is section 2 content")
62
+ for i in range(10):
63
  st.write(f"Content line {i}")
64
 
65
  st.header("Section 3", anchor="section3")
66
  st.write("This is section 3 content")
67
+ for i in range(10):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  st.write(f"Content line {i}")
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  # --- SHARED ON ALL PAGES ---
72
  st.logo(image="images/menu_book_60dp_75FBFD.png")