I want to use a CSS file to change the background of my web application, I have created a dynamic background with a CSS file and I want to use it in my application.
I have used the recommendations of the other forums, as they use it to put an image, but in this case I want to call a .css file to change the background and make my application look dynamic, so far I have not found documentation on the streamlit forums so I resort to the help of the community so that, in the future, if other users have the same concern they can use this module to have a guide of what to do.
I look forward to hearing from you.
Thank you very much
Actually, I want to display in the background of my application, a CSS file that generates a gradient style animation of 3 colors, the CSS code is as below:
What I want is to open and display the css as the background of the application, so that it looks dynamic. With images it already works but I am exploring if there is a way to work with a CSS file to give more dynamism to my web application.
The same principles apply. If you are familiar with css, you can see from the example which tags/classes to grab for your background. The element to grab is not body in this case; it’s .stApp (with an extra rule to remove the header if you want). The example shows how to include plain css. If you need to include any <script> .... </script> then you will need to use st.components.v1.html('<script>...</script>') instead.
import streamlit as st
st.title('A Random App')
st.write('Look at the pretty waves')
with open('./files/wave.css') as f:
css = f.read()
st.markdown(f'<style>{css}</style>', unsafe_allow_html=True)
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.