不要在窄窗口中显示 Read the Docs Sphinx TOC [英] Don't Display Read the Docs Sphinx TOC in Narrow Windows

查看:37
本文介绍了不要在窄窗口中显示 Read the Docs Sphinx TOC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于窄窗口,完整的阅读文档"窗口会显示内容,但当窗口变宽时,目录会显示为侧边栏,并且内容小于窗口宽度的一半.如何更改设置以便在显示 TOC 之前窗口必须更宽?

With a narrow window the full Read the Docs window displays content but when the window is widened a Table of Contents appears as a sidebar and the content is less than half the window width. How can the setting be changed so the window must be wider before the TOC is displayed?

我希望这个带有样式表、conf.py 参考和自定义布局的框架可以在source/_static 样式表.改变:

I expect this framework with a stylesheet, conf.py reference and custom layout would work with the appropriate css in the source/_static stylesheet. Changing:

.wy-nav-content {
    max-width: 1200px !important;
}

我假设这涉及测试屏幕宽度是否小于某个值,然后将 display_toc 设置为 false.类似的东西:

I assume this involves testing if screen width less than a certain value then set display_toc to false. Something like:

/* Set to display toc */
body {
  display_toc: true;
}

/* On narrow screens, set don't display toc */
@media screen and (max-width: 959px) {
  body {
    display_toc: false;
  }
}

推荐答案

sphinx_rtd_theme version 0.4.3 theme.css 似乎支持:

The sphinx_rtd_theme version 0.4.3 theme.css seems to support:

  • 小屏幕,最大宽度:480 像素
  • 中等屏幕,最大宽度:768 像素
  • 和更大的屏幕

我提取了 @media screen 和 (max-width: 768px) 代码并添加了一个新的宽度,如下所示.(我不懂 css 所以可能有更高效的代码.)

I extracted the @media screen and (max-width: 768px) code and added it with a new width as shown below. (I don't know css so there may be more efficient code.)

按照此流程,将 <html_static_path 文件夹中的 strong>custom.css 文件(默认为 _static),只包含所需的 css,例如

Following this process, put a custom.css file in the html_static_path folder (Default is _static) with just the required css, e.g.

@media screen and (max-width: 950px){
    .wy-body-for-nav{background:#fcfcfc}
    .wy-nav-top{display:block}
    .wy-nav-side{left:-300px}
    .wy-nav-side.shift{width:85%;left:0}
    .wy-side-scroll{width:auto}
    .wy-side-nav-search{width:auto}
    .wy-menu.wy-menu-vertical{width:auto}
    .wy-nav-content-wrap{margin-left:0}
    .wy-nav-content-wrap
    .wy-nav-content{padding:1.618em}
    .wy-nav-content-wrap.shift{position:fixed;min-width:100%;left:85%;top:0;height:100%;overflow:hidden}
}

更改 conf.pycustom.css 添加 html_css_files 选项:

Change conf.py to add html_css_files option for the custom.css:

html_css_files = ['custom.css']

这篇关于不要在窄窗口中显示 Read the Docs Sphinx TOC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆