我已经尝试了下面的命令标题,但我做不到。对于图像,我只是设法通过增加大小,使它填充整个页面。对于st.title()
和st.image
,有什么参数可以让我把它们集中起来吗?
title_alignment=
"""
<style>
#the-title {
text-align: center
}
</style>
"""
st.markdown(title_alignment, unsafe_allow_html=True)
发布于 2022-02-01 13:49:34
要使文本居中,您可以使用下面这样的标记:
#A streamlit app with two centered texts with different seizes
import streamlit as st
st.markdown("<h1 style='text-align: center; color: grey;'>Big headline</h1>", unsafe_allow_html=True)
st.markdown("<h2 style='text-align: center; color: black;'>Smaller headline in black </h2>", unsafe_allow_html=True)
也可以使用streamlit的列关键字,如下所示:
import streamlit as st
col1, col2, col3 = st.columns(3)
with col1:
st.write(' ')
with col2:
st.image("https://static.streamlit.io/examples/dog.jpg")
with col3:
st.write(' ')
这将创建容器,您可以在其中添加文本和图像。这样你就可以对图像进行居中。
https://stackoverflow.com/questions/70932538
复制相似问题