You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调整Streamlit侧边栏高度?现有CSS方案无效求助

求助:Streamlit侧边栏高度调整无效问题

我试了好几种用CSS调整Streamlit侧边栏高度的方法,下面是其中一种实现代码,但这个方案没解决我的问题。我在Streamlit论坛找到的建议方案也不管用,麻烦大家帮忙看看。

import streamlit as st 


st.markdown(
    """
    <style>
    [data-testid="stSidebar"][aria-expanded="true"] > div:first-child {
        height: 80% ;
    }
    [data-testid="stSidebar"][aria-expanded="false"] > div:first-child {
        height: 80%
    }
    </style>
    """,
    unsafe_allow_html=True,
)


st.sidebar.markdown("Adjust sidebar height")

当前侧边栏显示效果

内容的提问来源于stack exchange,提问作者Jamiu S.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.10 04:52:35