使用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. LCA在线算法ST算法

    求LCA(近期公共祖先)的算法有好多,按在线和离线分为在线算法和离线算法. 离线算法有基于搜索的Tarjan算法较优,而在线算法则是基于dp的ST算法较优. 首先说一下ST算法. 这个算法是基于RMQ ...

  2. Google搜索解析

    Google搜索解析 是一款相似于Google趋势的SEO 在 线keyword工具,其官方提出的口号是“看看全世界的人们都在搜索些什么”.利用Google搜索解析,能够比較特定区域.类别.时间范围以 ...

  3. SystemTap----常用变量、宏、函数和技巧

    http://blog.csdn.net/moonvs2010/article/category/1570309

  4. PCAP研究

    一.  pcap简介 封装了OS提供的底层抓包技术,对外提供一些统一的抓包(及发送)接口.实现这些功能的其他技术包括:BPF(Berkeley Packet Filter),DLPI(Data Lin ...

  5. java获取当前方法

    1.获取当前方法堆栈,我们一般用 StackTraceElement[] stes = Thread.currentThread().getStackTrace(); 想要获取当前方法,切记不够灵活, ...

  6. Java中泛型 问号的作用

    这是jdk1.5泛型的典型应用: 第一种写法,叫做使用泛型方法:    public <T extends Object> void thisIsT(List <T> list ...

  7. 第六篇:python高级之网络编程

    python高级之网络编程   python高级之网络编程 本节内容 网络通信概念 socket编程 socket模块一些方法 聊天socket实现 远程执行命令及上传文件 socketserver及 ...

  8. Couchbase用的端口

    文档首页: http://www.couchbase.com/documentation http://docs.couchbase.com/couchbase-manual-2.2/#prepara ...

  9. Bash常用快捷键

    快捷键 作用 Ctrl+A 把光标移动到命令行开头,如果我们输入的命令过长,想要把光标移动到命令行开头时使用 Ctrl+E 把光标移动到命令行结尾 Ctrl+C 强制终止当前的命令 Ctrl+L 清屏 ...

  10. AndroidManifest.xml中data标签中所有属性的含义

    属性(ATTRIBUTES): android:host 这个属性用户定义URI授权的主机部分,除非给过滤器也指定了<data>元素的scheme属性,否则这个属性没有意义. 注意:在An ...