Hello i have just started using Streamlit. I want to style a specific “container” with a specific “div class” but I have a problem.
This is my py code:
import streamlit as st
def local_css(file_name):
with open(file_name) as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
container1 = st.container()
div = """<div class = 'test1'>"""
divEnd = """</div>"""
container2 = st.container()
with container1:
container1.markdown(div, unsafe_allow_html=True)
st.header("Hello")
container1.markdown(divEnd, unsafe_allow_html=True)
with container2:
st.header("Hello2")
local_css("style.css")
This is my css:
.test1 {
background-color: black;
border: 1px solid #DCDCDC;
padding: 20px 20px 20px 70px;
padding: 5% 5% 5% 10%;
border-radius: 10px;
}
A picture from my program:
Why the “Hello” header is not in container1? Can you help me
Python version: 3.12.3
Streamlit version: 1.34.0