{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 向页面添加 HTML\n", "\n", "您可以通过调用 `ui.add_head_html` 或 `ui.add_body_html` 向页面添加 HTML。这对于添加自定义 CSS 样式或 JavaScript 代码非常有用。" ] }, { "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.add_head_html('''\n", " \n", "''')\n", "ui.label('RED').classes('my-red-label')\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 }