css Streamlit Multiple Page App侧边栏中文字的背景颜色、粗细和位置无法更改的问题

x4shl7ld  于 2022-12-01  发布在  其他
关注(0)|答案(1)|浏览(212)

流线型版本:1.13.0
中Homepage.py:

import streamlit as st

st.set_page_config(
        page_title= "Multipage App",
        page_icon="📁")

st.title("Main Page")

st.markdown('<style>div[class="css-6qob1r e1fqkh3o3"] {color:black; font-weight: 900; background: url("https://media2.giphy.com/media/46hpy8xB3MiHfruixn/giphy.gif");background-repeat: no-repeat;background-size:350%;} </style>', unsafe_allow_html=True)

st.markdown('<style>div[class="css-y3drt2 e1fqkh3o5"] {color:red; } </style>', unsafe_allow_html=True)#NOT WORKING-------------------------------------------

我想更改主页、应用程序和联系人文本的颜色、字体和位置。如何操作?

3qpi33ja

3qpi33ja1#

您可以使用via inline CSS and st.markdown来执行此操作,尽管它确实有些笨拙。

def _set_block_container_style(
    max_width: int = 1200,
    max_width_100_percent: bool = False,
    padding_top: int = 1,
    padding_right: int = 1,
    padding_left: int = 1,
    padding_bottom: int = 1,
):

if max_width_100_percent:
    max_width_str = f"max-width: 100%;"
else:
    max_width_str = f"max-width: {max_width}px;"
    
styl = f"""
    <style>
        .reportview-container .main .block-container{{
            {max_width_str}
            padding-top: {padding_top}rem;
            padding-right: {padding_right}rem;
            padding-left: {padding_left}rem;
            padding-bottom: {padding_bottom}rem;
        }}
        }}
    </style>

相关问题