我已经尝试过下面的标题命令,但失败了。对于图像,我只是通过增加尺寸使其居中,使其填充整个页面。有什么论据吗st.title()
and st.image
这让我可以将它们居中?
title_alignment=
"""
<style>
#the-title {
text-align: center
}
</style>
"""
st.markdown(title_alignment, unsafe_allow_html=True)
要使文本居中,您可以使用 Markdown,如下所示:
#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的column关键字,如下所示:
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(' ')
这将创建您可以添加文本和图像的容器。这样您就可以将图像居中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)