Update app.py
Browse files
app.py
CHANGED
@@ -1,71 +1,72 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Set page config
|
4 |
-
st.set_page_config(page_title="
|
5 |
-
|
6 |
-
#
|
7 |
-
|
8 |
-
<
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
"""
|
16 |
|
17 |
-
# Inject the
|
18 |
-
st.components.v1.html(
|
|
|
|
|
|
|
19 |
|
20 |
-
# Regular Streamlit content
|
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(
|
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(
|
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(
|
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")
|