首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >修改Sphinx主题“阅读文档”的内容宽度

修改Sphinx主题“阅读文档”的内容宽度
EN

Stack Overflow用户
提问于 2014-04-22 14:09:57
回答 3查看 28.1K关注 0票数 45

我在文档中使用了'Read the Docs‘Sphinx主题。在原始主题中,如下所示

http://read-the-docs.readthedocs.org/en/latest/theme.html

内容或主布局宽度设计为移动友好。然而,对于我的项目,我希望这个范围更宽一点。我不知道HTML,因此,如果有人能给我一些线索来增加内容(布局)宽度,我将不胜感激。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2015-11-10 16:57:09

另一种选择是在source/_static中创建一个仅包含所需样式表的样式表,例如

代码语言:javascript
复制
.wy-nav-content {
    max-width: none;
}

代码语言:javascript
复制
.wy-nav-content {
    max-width: 1200px !important;
}

确保在source/conf.py中引用了该目录-我相信默认情况下会有一行执行此操作,即

代码语言:javascript
复制
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

然后在source/_templates/layout.html中创建自定义布局,并执行以下操作以包含样式表

代码语言:javascript
复制
{% extends "!layout.html" %}
{% block extrahead %}
    <link href="{{ pathto("_static/style.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}

假设您将样式表命名为style.css

票数 50
EN

Stack Overflow用户

发布于 2015-10-02 07:40:58

这里的解决方案有点老套。如果你想包含样式,并有一个css覆盖,让它在RTD上工作,你会想要这样的东西。

代码语言:javascript
复制
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'

if not on_rtd:  # only import and set the theme if we're building docs locally
  import sphinx_rtd_theme
  html_theme = 'sphinx_rtd_theme'
  html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
  html_style = 'css/custom.css'
else:
  html_context = { 
    'css_files': [
        'https://media.readthedocs.org/css/sphinx_rtd_theme.css',
        'https://media.readthedocs.org/css/readthedocs-doc-embed.css',
        '_static/css/custom.css',
    ],  
  }   

我自己测试过,它似乎在本地和RTD上都可以工作。大量抄袭自https://blog.deimos.fr/2014/10/02/sphinxdoc-and-readthedocs-theme-tricks-2/

票数 7
EN

Stack Overflow用户

发布于 2014-04-30 03:59:22

我会在css中对其进行修改。您应该搜索文件theme.css (它位于“sphinx_rtd_theme/static/css/teme.css”的文档源码中)。

复制该文件并将其放入您的sphinx _static目录中。在css文件中,您可以进行所需的所有布局更改。(如果您从未使用过css文件,则可能需要阅读一些有关css文件的内容。)

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23211695

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档