CSS Hacks have weird behaviour (of course)

When I run this code, something weird can happen sometimes, but not always. Every reload has a chance to have the bug:

import streamlit as st

st.write("# ")

hide_streamlit_style = """
                <style>
                    #MainMenu {visibility: hidden;}
                    footer {visibility: hidden;}
                    #root > div:nth-child(1) > div > div > div > div > section > div {padding-top: 2rem;}
                    #root > div:nth-child(1) > div > div > div > div > section > div > div {padding-top: 2rem;}
                </style>
                """
st.markdown(hide_streamlit_style, unsafe_allow_html=True)

st.sidebar.write("whatever")

the st.write line needs to be present for this bug to occur.

Refreshing the page sometimes yields this weird state with the sidebar raised (there’s whitespace at the bottom and the x is closer to the top):

and other times it’s just the normal expected output:

Streamlit 1.13.0, Chrome, Win 10

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.