{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 页面布局\n", "通过 `ui.header`、`ui.footer`、`ui.left_drawer` 和 `ui.right_drawer`,您可以向页面添加额外的布局元素。`fixed` 参数控制元素是滚动还是固定在屏幕上。`top_corner` 和 `bottom_corner` 参数指示抽屉是否应扩展到页面的顶部或底部。有关可能属性的更多信息,请参阅 。通过 `ui.page_sticky`,您可以将元素“粘”在屏幕上。有关更多信息,请参阅 。" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from nicegui import ui\n", "\n", "@ui.page('/page_layout')\n", "def page_layout():\n", " ui.label('CONTENT')\n", " [ui.label(f'Line {i}') for i in range(100)]\n", " with ui.header(elevated=True).style('background-color: #3874c8').classes('items-center justify-between'):\n", " ui.label('HEADER')\n", " ui.button(on_click=lambda: right_drawer.toggle(), icon='menu').props('flat color=white')\n", " with ui.left_drawer(top_corner=True, bottom_corner=True).style('background-color: #d7e3f4'):\n", " ui.label('LEFT DRAWER')\n", " with ui.right_drawer(fixed=False).style('background-color: #ebf1fa').props('bordered') as right_drawer:\n", " ui.label('RIGHT DRAWER')\n", " with ui.footer().style('background-color: #3874c8'):\n", " ui.label('FOOTER')\n", "\n", "ui.link('show page with fancy layout', page_layout)\n", "\n", "# ui.run()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py311", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.7" } }, "nbformat": 4, "nbformat_minor": 2 }