[英]How to center align the image with reRestructuredText?
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.但是,图像不是居中对齐,而是右对齐,我看到生成的 HTML 如下。
<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."它被定义为 align-center 类,与解释相反:“图像的对齐方式,相当于 HTML 标签的“对齐”属性。
I even tried to have the CSS.我什至试图拥有 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?这有什么问题?
As well as setting the :align: center
flag, add the following CSS to your stylesheet:除了设置
:align: center
标志外,还将以下 CSS 添加到样式表中:
img.align-center {
margin-left: auto;
margin-right: auto;
display: block;
}
did you try margin:0px auto;
您是否尝试过
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使用以下技巧将图像居中对齐
.. raw:: html
<h1 align="center">
<a href="your href link"><img width="200" src="image link" alt="text"></a>
</h1>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.