Environment:
- Python 3.12.0
- Streamlit 1.45.1
- Windows 11
Problem Description:
In my Streamlit application, every call to st.markdown()
causes all page elements to shift downward. This creates accumulating white space and misaligned layouts, especially noticeable when applying custom CSS styles.
import streamlit as st
Each call to this function pushes content down
main.py:
pages = {
"examples1": [
st.Page("pages/example1111.py")
]
}
def apply_css():
css = """
<style>
.stHeading {
display: flex;
justify-content: center;
width: 100%;
}
.stSelectbox > div > div {
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
transition: all 0.3s;
}
.stSelectbox > div > div:hover {
box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
</style>
"""
st.markdown(css, unsafe_allow_html=True)
apply_css()
pg = st.navigation(pages,expanded=False)
pg.run()
in other pages will creates accumulating white space just like the image.