import streamlit as st
st.set_page_config(
page_title="Login",
page_icon="🔏",
layout="wide")
col1, col2 = st.columns(2)
with col1:
with st.container(key="image-container"):
st.image("https://static.streamlit.io/examples/dog.jpg")
with col2:
st.image("https://static.streamlit.io/examples/dog.jpg")
what i’m trying to do is to make the col content to take the whole height of a page like in the picture bellow(the result you see in the picture below, I played with the browser inpect to get this result). is there a way please to get the same result using streamlit.
thanks
This isn’t necessarily a great solution, because the width won’t be automatically adjusted, and so the images can overlap or be spaced out depending on the width of your screen, but you can add custom css like this:
import streamlit as st
st.set_page_config(
page_title="Login",
page_icon="🔏",
layout="wide")
col1, col2 = st.columns(2)
with col1:
with st.container(key="image-container"):
st.image("https://static.streamlit.io/examples/dog.jpg")
with col2:
st.image("https://static.streamlit.io/examples/dog.jpg")
st.html(
"""
<style>
img {
height: 100%;
position: fixed;
top: 0;
}
</style>
"""
)
If you want only the left column, with the key “image-container” to be resized, you can do this:
import streamlit as st
st.set_page_config(
page_title="Login",
page_icon="🔏",
layout="wide")
col1, col2 = st.columns(2)
with col1:
with st.container(key="image-container"):
st.image("https://static.streamlit.io/examples/dog.jpg")
with col2:
st.image("https://static.streamlit.io/examples/dog.jpg")
st.html(
"""
<style>
.st-key-image-container img {
height: 100%;
position: fixed;
top: 0;
}
</style>
"""
)
That’s likely happening because st.columns are dynamic, and if you make the window narrow enough, the columns go away and the contents of each one just become one after the other (as if they weren’t in columns). Though it’s probably possible to get around this (and make the columns always work like columns, even if the window gets very narrow), I don’t think it would be very easy.
For example, all the apps you see in the Streamlit docs are embedded. When you visit an app and add ?embed=true to the end of the URL, it modifies the display of the app for embedding.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.