欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > 241006-Gradio中Chatbot通过CSS自适应调整高度

241006-Gradio中Chatbot通过CSS自适应调整高度

2024/10/25 12:29:37 来源:https://blog.csdn.net/qq_33039859/article/details/142727796  浏览:    关键词:241006-Gradio中Chatbot通过CSS自适应调整高度

A. 最终效果

在这里插入图片描述

B. 参考代码

import gradio as grCSS = """
.contain { display: flex; flex-direction: column; }
.gradio-container { height: 100vh !important; } 
#component-0 { height: 100%; }
#chatbot { flex-grow: 1; overflow: auto;}
#tab_item_4 { height: calc(100vh - 83px);}
#tab_item_4 .gap { height: 100%; }
#tab_item_4 .gap #chatbot1 { flex-grow: 1; height: auto !important;}#tab_item_5 { height: calc(100vh - 83px);}
#tab_item_5 .gap { height: 100%; }
#tab_item_5 .gap #chatbot2 { flex-grow: 1; height: auto !important;}
"""with gr.Blocks(css=CSS) as demo:# with gr.Blocks() as demo:with gr.Tabs(elem_classes="tab_id_123"):with gr.Tab('I want this tap', elem_id="tab_item_4"):chatbot = gr.Chatbot(elem_id="chatbot1")msg = gr.Textbox()clear = gr.Button("Clear")with gr.Tab('I want this ta2p', elem_id="tab_item_5"):chatbot = gr.Chatbot(elem_id="chatbot2")msg = gr.Textbox()clear = gr.Button("Clear")# with gr.Blocks(css=CSS) as demo:
#     chatbot = gr.Chatbot(elem_id="chatbot")
#     msg = gr.Textbox()
#     clear = gr.Button("Clear")demo.launch(inbrowser=True, server_name='0.0.0.0', server_port=5001)

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com