如何将图像与reRestructedText居中对齐?
这篇文章说以下指令是一种对齐图像的方法。
.. image:: ./imgs/code.jpg
:width: 400px
:align: center
但是,图像不是居中对齐,而是右对齐,我看到生成的 HTML 如下。
<img alt="./imgs/code.jpg" class="align-center" src="./imgs/code.jpg" style="width: 400px;" />
它被定义为align-center类,与解释相反:“图像的对齐方式,相当于HTML标签的“align”属性。”
我什至尝试过使用CSS。
.. raw:: html
<style type="text/css">
.align-center {
text-align: center;
border: 0px;
}
</style>
而且它也不起作用。
这有什么问题吗?
This post says the following directive is a way to align image.
.. image:: ./imgs/code.jpg
:width: 400px
:align: center
However, the image is not center aligned, but right aligned, and I see the HTML generated as follows.
<img alt="./imgs/code.jpg" class="align-center" src="./imgs/code.jpg" style="width: 400px;" />
It's defined in as the align-center class contrary to the explanation : "The alignment of the image, equivalent to the HTML tag's "align" attribute."
I even tried to have the CSS.
.. raw:: html
<style type="text/css">
.align-center {
text-align: center;
border: 0px;
}
</style>
And it also doesn't work.
What's wrong with this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据此网站: docutils 您可以使用如下所示的特定指令:
According to this site: docutils you can use a specific directive like the following:
除了设置
:align: center
标志之外,还将以下 CSS 添加到样式表中:As well as setting the
:align: center
flag, add the following CSS to your stylesheet:您是否尝试过
margin:0px auto;
如果这对您不起作用,则意味着还有其他样式导致此行为。
did you try
margin:0px auto;
If this doesn't work for you, it means there are other styling causing this behavior.
使用以下技巧将图像居中对齐
Use the following hack to align the image in the center