如何使用Markdown将文本居中?

时间:2018-11-21 19:19:38

标签: html css twig markdown grav

如何使用Markdown将商品居中?我正在寻找可在Grav中使用的解决方案。我在互联网上找不到任何东西,这让我有点沮丧。

3 个答案:

答案 0 :(得分:2)

Markdown本身不支持此功能但是您可以将Markdown打包为HTML。

根据经验,Markdown的大多数“风味”会将其呈现为居中文本:

<p style="text-align: center;">Centered text</p>

对于Grav,特别是their documentation states,您应该执行以下步骤:

在系统配置文件user/config/system.yaml中,确保激活markdown extra选项:

pages:
  markdown:
    extra: true

在包装标签中,确保添加参数markdown="1"以激活降价内容的处理:

<div class="myWrapper" markdown="1">
# my markdown content

this content is wrapped into a div with class "myWrapper"
</div>

答案 1 :(得分:1)

我还想添加标题,例如可以使用标签

# Title
## title 2

相当于

<h1> Title </h1>
<h2> Title 2 </h2>

通过标题,您可以使用以下方法对齐文本:

<!-- title only -->
<h1 align="center"> Title </h1>

<!-- title with div -->
<div align="center"> <h1 align="center"> Title inside div! </h1> </div>

<!-- title with span (you can render emojis or markdown inside it) -->
<span align="center"> <h1> :star: My Career: </h1> </span>

答案 2 :(得分:0)

对我来说,它使用了以下技巧:在不关闭 div 标签的情况下在顶部添加标签 div。这使得整个 Markdown 集中化

<div align="center">
相关问题