是的,但它非常笨拙,需要自定義CSS來說明每個圖像的寬度。
下面是獅身人面像生成我的HTML:根據您的主題
<div class="figure align-center">
<img src="check_validity.png" />
<div class="legend">
<p>Some text</p>
<p>Another sentence</p>
</div>
</div>
,你將需要:
- 獲得圖像(WI)的寬度
- 得到內容區域的寬度(WCA),如果它是一個流體,可變寬度區域可能是不可能的
- 計算左邊距:LM =(WCA-WI)/ 2
- 將LM用作CSS選擇器的段落塊的左邊距
僅使用表格就容易得多。歡迎來到90年代!
這裏是在reST標記:
.. rst-class:: table-center
+--------------------------------+
| .. figure:: check_validity.png |
| |
| .. |
| |
| Left: the source layer |
| |
| Right: in blue the valid |
| layer, in green the invalid |
| layer and in red the error |
| layer |
+--------------------------------+
而且你將需要自定義樣式添加到您的CSS文件:
table.table-center {
margin-left: auto;
margin-right: auto;
}
你想中心相對於頁面圖片對齊?對於文本,您是否想要將其與頁面或圖像相對齊? –
我想對齊相對於圖像的左側文字..你知道這是否可能嗎? – matteo