Update app.py
Browse files
app.py
CHANGED
@@ -1,60 +1,84 @@
|
|
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 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</div>
|
38 |
-
|
39 |
-
<
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
55 |
|
56 |
-
|
57 |
-
|
58 |
|
59 |
|
60 |
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
+
# Set basic page config
|
4 |
+
st.set_page_config(page_title="App with Sticky Header", layout="wide")
|
5 |
|
6 |
+
# Create an HTML iframe component that contains both the header and content
|
7 |
+
iframe_html = """
|
8 |
+
<!DOCTYPE html>
|
9 |
+
<html>
|
10 |
+
<head>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
font-family: sans-serif;
|
16 |
+
}
|
17 |
+
.sticky-header {
|
18 |
+
position: sticky;
|
19 |
+
top: 0;
|
20 |
+
background-color: #262730;
|
21 |
+
color: white;
|
22 |
+
padding: 1rem;
|
23 |
+
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
24 |
+
z-index: 1000;
|
25 |
+
display: flex;
|
26 |
+
justify-content: space-between;
|
27 |
+
align-items: center;
|
28 |
+
}
|
29 |
+
.content {
|
30 |
+
padding: 1rem;
|
31 |
+
}
|
32 |
+
.nav-link {
|
33 |
+
color: white;
|
34 |
+
margin-left: 1rem;
|
35 |
+
text-decoration: none;
|
36 |
+
}
|
37 |
+
.nav-link:hover {
|
38 |
+
text-decoration: underline;
|
39 |
+
}
|
40 |
+
</style>
|
41 |
+
</head>
|
42 |
+
<body>
|
43 |
+
<div class="sticky-header">
|
44 |
+
<h2>My Application</h2>
|
45 |
+
<div>
|
46 |
+
<a href="#section1" class="nav-link">Section 1</a>
|
47 |
+
<a href="#section2" class="nav-link">Section 2</a>
|
48 |
+
<a href="#section3" class="nav-link">Section 3</a>
|
49 |
+
</div>
|
50 |
</div>
|
51 |
+
<div class="content">
|
52 |
+
<h3 id="section1">Section 1</h3>
|
53 |
+
<p>This is the content for section 1.</p>
|
54 |
+
<!-- Generate some dummy content -->
|
55 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
56 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
57 |
+
|
58 |
+
<h3 id="section2">Section 2</h3>
|
59 |
+
<p>This is the content for section 2.</p>
|
60 |
+
<!-- Generate some dummy content -->
|
61 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
62 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
63 |
+
|
64 |
+
<h3 id="section3">Section 3</h3>
|
65 |
+
<p>This is the content for section 3.</p>
|
66 |
+
<!-- Generate some dummy content -->
|
67 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
68 |
+
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
|
69 |
+
</div>
|
70 |
+
</body>
|
71 |
+
</html>
|
72 |
+
"""
|
73 |
|
74 |
+
# Use streamlit components to render the iframe
|
75 |
+
# Note: We're placing this in a container to give it proper dimensions
|
76 |
+
container = st.container()
|
77 |
+
with container:
|
78 |
+
st.components.v1.html(iframe_html, height=600, scrolling=True)
|
79 |
|
80 |
+
# You can still add Streamlit content below if needed
|
81 |
+
st.write("This content is outside the iframe")
|
82 |
|
83 |
|
84 |
|