Markdown 在img中添加自定义CSS样式
目前,我正在使用hugo material主题: 当我写下下面的内容时Markdown 在img中添加自定义CSS样式,markdown,hugo,Markdown,Hugo,目前,我正在使用hugo material主题: 当我写下下面的内容时 ![practice-signup-1](/images/practice-signup-1.png) Hugo将生成以下HTML代码 <p><img src="https://investing.jstock.co/images/practice-signup-1.png" alt="practice-signup-1"></p> 但是,我希望在我的img标签中添加以下样式 &l
![practice-signup-1](/images/practice-signup-1.png)
Hugo将生成以下HTML代码
<p><img src="https://investing.jstock.co/images/practice-signup-1.png" alt="practice-signup-1"></p>
但是,我希望在我的img标签中添加以下样式
<p><img src="https://investing.jstock.co/images/practice-signup-1.png" alt="practice-signup-1" style="max-width: 100%; width: 50%; height: auto;"></p>
我想知道,我怎样才能做到这一点呢?您可以为它创建短代码 在
/themes/your theme dir/layouts/shortcodes/img.html
中创建自己的短代码
<p><img src="{{ .Get 0 }}" alt="practice-signup-1" style="max-width: 100%; width: 50%; height: auto;"></p>
然后在你的帖子中使用简短的代码:
{{< img https://investing.jstock.co/images/practice-signup-1.png >}}
{{}}
另一种方法是,您可以在css文件中添加样式,而不是创建内联样式。您可以为它创建短代码 在
/themes/your theme dir/layouts/shortcodes/img.html
中创建自己的短代码
<p><img src="{{ .Get 0 }}" alt="practice-signup-1" style="max-width: 100%; width: 50%; height: auto;"></p>
然后在你的帖子中使用简短的代码:
{{< img https://investing.jstock.co/images/practice-signup-1.png >}}
{{}}
另外,您可以在css文件中添加样式,而不是创建内联样式。您可以将原始HTML放入标记文件中。因此,如果您有一个需要特殊样式的图像,只需将
代码粘贴到标记文件中。您可以将原始HTML放入标记文件中。因此,如果您有一个需要特殊样式的图像,只需将代码粘贴到标记文件中。可能的重复,也可能的重复,也可能的重复