嵌入html代码
你可以在 docusaurus 的 .md 文档中直接编写 html 代码,示例:
示例.md
<div class="custom-style-container">
<style>
.custom-style-container {
font-family: 'Arial', sans-serif;
background-color: lightblue;
padding: 20px;
}
.custom-style-container h1 {
font-size: 36px;
font-weight: bold;
color: #2c3e50;
text-align: center;
}
.custom-style-container p {
font-size: 16px;
color: #555;
line-height: 1.8;
text-align: justify;
}
.custom-style-container .important {
font-weight: bold;
color: red;
text-decoration: underline;
}
.custom-style-container a {
text-transform: uppercase;
text-decoration: none;
color: #2980b9;
font-weight: bold;
}
</style>
<h1>欢迎来到我的网页</h1>
<p>这是一个包含 CSS 字体和文本样式的示例。你可以看到如何使用不同的 CSS 属性来控制文本的外观。</p>
<p>请注意,<span class="important">这段文本很重要</span>,它展示了加粗和下划线效果。</p>
<p>访问 <a href="#">我的链接</a>,了解更多信息。</p>
</div>
效果,html 代码将被渲染:
欢迎来到我的网页
这是一个包含 CSS 字体和文本样式的示例。你可以看到如何使用不同的 CSS 属性来控制文本的外观。
请注意,这段文本很重要,它展示了加粗和下划线效果。
访问 我的链接,了解更多信息。
note
最好将 mdx 解析器设置为 format: 'detect'
,确保对 .md 文档使用 Markdown 格式解析器,而不是 mdx 解析器。