75 lines
1.9 KiB
Python
75 lines
1.9 KiB
Python
"""共享界面布局样式。"""
|
|
import streamlit as st
|
|
|
|
COMPACT_CSS = """
|
|
<style>
|
|
header[data-testid="stHeader"] {
|
|
background: transparent;
|
|
height: 2.5rem;
|
|
}
|
|
div[data-testid="stDecoration"] {
|
|
display: none;
|
|
}
|
|
.block-container {
|
|
padding-top: 1.1rem !important;
|
|
padding-bottom: 1.2rem !important;
|
|
padding-left: 2rem !important;
|
|
padding-right: 2rem !important;
|
|
max-width: 1200px;
|
|
}
|
|
section[data-testid="stSidebar"] > div:first-child {
|
|
padding-top: 0.75rem !important;
|
|
padding-bottom: 0.75rem !important;
|
|
}
|
|
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h1,
|
|
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h2,
|
|
section[data-testid="stSidebar"] [data-testid="stMarkdownContainer"] h3 {
|
|
margin: 0.15rem 0 0.2rem 0 !important;
|
|
padding: 0 !important;
|
|
line-height: 1.2 !important;
|
|
}
|
|
section[data-testid="stSidebar"] [data-testid="stCaptionContainer"] {
|
|
margin-top: 0 !important;
|
|
margin-bottom: 0.55rem !important;
|
|
}
|
|
section[data-testid="stSidebar"] [data-testid="stSidebarNavLink"],
|
|
section[data-testid="stSidebar"] a[data-testid="stPageLink-NavLink"] {
|
|
padding-top: 0.35rem !important;
|
|
padding-bottom: 0.35rem !important;
|
|
margin: 0.05rem 0 !important;
|
|
}
|
|
div[data-testid="stMainBlockContainer"] > div {
|
|
gap: 0.65rem;
|
|
}
|
|
div[data-testid="stVerticalBlock"] {
|
|
gap: 0.55rem !important;
|
|
}
|
|
div[data-testid="stHorizontalBlock"] {
|
|
gap: 0.75rem !important;
|
|
}
|
|
[data-testid="stMetric"] {
|
|
background: #EDF2F7;
|
|
border-radius: 0.55rem;
|
|
padding: 0.55rem 0.8rem;
|
|
}
|
|
[data-testid="stMetricValue"] {
|
|
font-size: 1.55rem !important;
|
|
}
|
|
h1 {
|
|
font-size: 1.7rem !important;
|
|
margin-bottom: 0.2rem !important;
|
|
}
|
|
h2, h3 {
|
|
margin-top: 0.35rem !important;
|
|
margin-bottom: 0.25rem !important;
|
|
}
|
|
hr {
|
|
margin: 0.4rem 0 !important;
|
|
}
|
|
</style>
|
|
"""
|
|
|
|
|
|
def apply_compact_layout():
|
|
st.markdown(COMPACT_CSS, unsafe_allow_html=True)
|