使用role指令达到目的。

We can put following lines at the beginning of our RST file to specify its style.

.. raw:: html

    <style>.red {color:red}</style>

然后使用role指令:
.. role:: red
:class: red
调用role指令:
This is an :red:`inline text`.

which translates into a html rendering of

.. This is an <span class="red">inline text</span>.  ..
如何分离css:

I found the other answers very helpful. I am not very familiar with Sphinx but I am using it for a project. I too wanted the strike-through ability and have got it working based on the previous answers. To be clear, I added my strikethrough role as gozzilli mentioned but I saved it inside my conf.py using the rst_prolog variable as discussed in the stack overflow thread here. This means that this role is available to all of your rest files.

I then extended the base html template as described above by creating layout.htmlwithin _templatesinside my source directory. The contents of this file are:

{% extends "!layout.html" %}
{% set css_files = css_files + ["_static/myStyle.css"] %}

This basically includes a custom css file to all your built default html docs.

Finally, in my _static directory within my source directory I included the file myStyle.css which contains:

.strike {
text-decoration: line-through;
}

Which the other answers have already provided.

I am merely writing this answer as it wasn't obvious to me with my limited Sphinx experience which files to edit.

参考了:

http://stackoverflow.com/questions/6518788/rest-strikethrough

http://stackoverflow.com/questions/4669689/how-to-use-color-in-text-with-restructured-text-rst2html-py-or-how-to-insert-h

http://stackoverflow.com/questions/9698702/custom-css-styles-in-sphinx

sphinx插入css的更多相关文章

  1. JavaScript 动态插入 CSS

    写组件时有时想把一些组件特性相关的 CSS 样式封装在 JS 里,这样更内聚,改起来方便.JS 动态插入 CSS 两个步骤就可以 创建一个 style 对象 使用 stylesheet 的 inser ...

  2. html中插入css和js

    插入css: HTML周明华添加css样式的方法有很多种,常见的有一下几种:. 1.直接标签后添加如: <html> <div style="background:red; ...

  3. 在网页中插入CSS样式表的几种方法

    1. 链入外部样式表 链入外部样式表是把样式表保存为一个样式表文件,然后在页面中用<link>标记链接到这个样式表文件,这个<link>标记必须放到页面的<head> ...

  4. sphinx插入代码

    示例的Python源代码或者交互界面都可以使用标准reST模块实现.在正常段落后面跟着 :: 开始,再加上适当缩进. 交互界面需包含提示及Python代码的输出. 交互界面没有特别的标记. 在最后一行 ...

  5. Js 动态插入css js文件

    function loadjscssfile(filename,filetype){ var file, //动态插入的文件 doc = document; if(filetype == " ...

  6. HTML页面中插入CSS样式的三种方法

    1. 外部样式 当样式需要应用于很多页面时,外部样式表将是理想的选择.在使用外部样式表的情况下,你可以通过改变一个文件来改变整个站点的外观.每个页面使用<link>标签链接到样式表. &l ...

  7. 巧用函数实现js插入css样式

    我用的是webstorm,当写css 样式时候,会没有提示,可以按Ctrl+Alt+Space.

  8. 插入CSS的方法

    传送门    选择器  selector {declaration1; declaration2; ... declarationN }   例:   p { text-aligh:center; } ...

  9. 插入css样式表的三种方法

    http://www.w3school.com.cn/css/css_howto.asp http://www.runoob.com/css/css-howto.html 当读到一个样式表时,浏览器会 ...

随机推荐

  1. 覆盖equals的时候总要覆盖hashCode

    import java.util.HashMap; public class Student { private String name ; private String id; public Stu ...

  2. 9.26 noip模拟试题

    魔术球问题弱化版(ball.c/.cpp/.pas) 题目描述 假设有 n 根柱子,现要按下述规则在这 n 根柱子中依次放入编号为 1,2,3,…的球. (1)每次只能在某根柱子的最上面放球. (2) ...

  3. Asp.net Mvc 第一回 安装,并使ASP.NET MVC页面运行起来

    直接上图吧: 1.到官方网站下载:http://www.asp.net/mvc/ Codeplex开源站点:http://www.codeplex.com/aspnet(下载源代码及Futures包) ...

  4. heibernate增删改查总结一下自己的不足

    难点也就我不熟悉的是数据库语句的书写,要加强复杂查询语句的书写 /* 简单的在共享类中已经可以用的了 * 总结: * * --------------------------------------查 ...

  5. Jquery不生效

    $(document).ready(function(){这个都没有生效, 1.网上查了说是jquery的路劲引入的有问题,经查并不是这个问题 2.换了一个jquery的版本,发现生效了. 原不生效文 ...

  6. 强制关闭myeclipse出现的问题

    重启时,可能会出现打不开关闭前所在的workspace.其他workspace可以正常打开. 今天遇到这个问题,以前就遇到过,但是忘记如何解决了.今天在我等了十多分钟后,神奇的myeclipse自己起 ...

  7. 比较两份文件的异同-beyond compare

    比较两份文件的异同-beyond compare 今天又学到一个知识,比较两次文件的 异同.  哈哈 谢谢领导

  8. Objective-C和C++的区别

    1.都是有C语言延伸而来2.OC是完全动态的,C++是部分动态的3.OC不支持多继承,通过代理 类别 协议优雅的实现了相关的一系列特性4.调用机制不同OC里面叫发送消息  C++叫做调用函数数5.OC ...

  9. CDH5 集群安装教程

    一.虚拟机的安装和网络配置. 1.虚拟机安装. 2.安装CentOS-6.5 64位版本. 桥接模式: Master: 内存:3G: 硬盘容量40G: 4核: Slave: 内存2G: 硬盘容量30G ...

  10. Windows程序设计 贪吃蛇c

    看Windows程序有段时间了,终于动手写东西.贪吃蛇算是一个开始吧,下面的贪吃蛇很简单,也有很多地方需要修改,还有情况没有考虑QAQ 但这不是我的目的了... 思路很简单:建个链表储存蛇身节点即可. ...