Streamlit App (after initial loading) starts in the middle of the page instead of the top

Hello, I want my streamlit app to start at the top of the page after it is loaded, but for some reason it just jumps to the middle of the page. Is there anyway I can configure my app so it start at the top of the page every time itโ€™s loaded?

1 Like

Hi @corsilt, welcome to the Streamlit community!

Without seeing your code, itโ€™s pretty hard to make any suggestions. Do you have a code snippet that demonstrates this behavior?

Best,
Randy

Hi Randy, I am encountering the same problem, I was hoping you can through me some light.
this is one of the two pages:

I had the same even before splitting my app into pages, with pretty much the same code.
Thanks a lot for any help.

Hi @franasa -

Unfortunately, your app doesnโ€™t display this behavior on my Ubuntu machine. What size browser window are you using?

Best,
Randy

Thanks @randyzwitch for your answer, I see this on Chrome on an android phone, an iPad and an iPhone, and on Chrome and Firefox on Fedora 35 Linux, donโ€™t have windows or mac at hand now.
The page starts on top and after less than one second jumps to the selection section.

edit: 1920 x 1001 is my laptopโ€™s browser size, just tried other sizes, same behaviour.

I am also experiencing this issue with my webpage. Was a solution ever provided?

Unfortunately not, since itโ€™s so hard to reproduce.

Hello.

I think I have the same problem, in which after browsing the pages of my streamlit app, and for example being on a page other than the initial one (main), my streamlit app reloads and returns to the initial page, or I change tab in the browser and when I return to the tab of my streamlit app it reloads too; I thought it was because of the browser used but both firefox, edge and chrome, I get the same result, differentiating the times in which the streamlit app rerun automatically.

Thanks a lot for any help.

I have the same issue. I go to my http://localhost:8501/, and Home.py loads fine but it jumps to the middle of the page.
Moreover, I have a multipage app. So when I go to other page, and then I come back to Home.py, the page is displayed correctly (Iโ€™m on Chrome).

I fixed by avoiding adding st.subheader in the middle of the page. :melting_face:

1 Like

Hi corsilt, its my first message here,
Iโ€™ve had the exact same problem and it was due to the way I use line breaks.
The anchor that made my app jump in the middle was a "st.markdown(โ€˜#โ€™)',
Iโ€™ve removed it and now it start at the top !

You can add a โ€œst.write(โ€˜#โ€™)โ€ on top of your page.

2 Likes

thank you! adding the st.write(โ€œ#โ€) to the top was what finally worked for me.