Sorry for the late response, I am not sure how to approach this. I did use this approach to change the sidebar image only, you can see that I call the [data-testid=“stSidebar”] div and set an image - code below:
Go to the white bar, inspect element and find the information on the name on the right. Try to change the name of the data-testid in the code below ([data-testid=“stSidebar”]) to the name you found on the right:
It takes a bit of practice to find the correct css classes/attributes to use, and between Streamlit versions those CSS classes will change which is why you need to be able to find them by yourself through the devtools
As far as I know the Lottie JSON encodes a full animation. You would probably need to extract an image from the animation to use as background image using Lottie Editor: Edit and customize Lottie animations - LottieFiles . The browser won’t know how to interpret the Lottie animation to use as background.
hi, i have been trying to add background image for my web page from my local disk ,but its not working the code you provided,here is my code: from PIL import Image
Title of the web app
st.title(“NOVO STAR eCRF Generator”)
Load the background image
st.cache(allow_output_mutation=True)
def get_base64_of_bin_file(bin_file):
with open(bin_file, ‘rb’) as f:
data = f.read()
return base64.b64encode(data).decode()
Thank you so much, this worked for me too.
As mine is a chat window, i have added a background with the code below(same as yours) but the scroll is not working. any suggestions?
titleimg = “static/Picture7.png”
def set_bg_hack(main_bg):
# set bg name
main_bg_ext = “png”
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.