在sphinx RST中合并图像响应类的方法?

时间:2016-01-16 14:41:49

标签: twitter-bootstrap python-sphinx

因此,在rst使用sphinx格式时,可以使用以下网址将图片添加到网页中:

.. image:: images/pic.png
    :align: center

但这不适用于需要类img-responsive的响应式引导程序。有办法解决这个问题吗?目前我的解决方案是编写html原始代码:

.. raw:: html

  <div class="container-fluid">
    <div class="row">
      <img src="images/pic.png" class="img-responsive"> 
    </div>
  </div>

但这很笨拙。有没有更简洁的方法来处理这个?

1 个答案:

答案 0 :(得分:0)

我正在寻找同样的事情,遗憾地发现你的问题没有答案。经过更多的搜索,我确实遇到了这个Sphinx扩展:

https://pypi.python.org/pypi/sphinxcontrib-css3image

基本上,它允许您在新指令(基于图像)中指定其他设置,如下所示:

.. css3image:: /_images/foo.png
  :margin: 10px 10px 10px 10px
  :margin-left: 10px
  :margin-right: 10px
  :margin-top: 10px
  :border-radius: 10px
  :transform-origin: 10px 10px
  :translate: 10px 10px
  :translateY: 10px
  :translateX: 10px
  :scaleX: 2.0
  :scaleY: 2.0
  :rotate: -10deg

我在源代码中也注意到你可以指定类:

https://github.com/FabriceSalvaire/sphinx-css3image/blob/master/sphinxcontrib/css3image.py#L123-L148

我刚安装它并稍微玩了一下。好像它至少做了你想要的一部分?