How to center website content (body and navigation bar) in rtd sphinx?
Asked Answered
V

1

7

I am creating documentation using the Read the Docs theme for Sphinx documentation. I am trying to center the entire webpage - both the body and the left navigation bar, such that if the width of the window increases, the margin on both the left and the right sides increases equally. Currently, all of the content is fixed to the left side of the screen.

I have done some experimenting with the css style sheet and found that by replacing all instances of "margin:0" with "margin:0 auto", the body shifts to center justifies. however, the navigation bar is still locked to the left side of the screen. Any suggestions on how to do this? I have very little experience with html and css. I can upload files if necessary.

Violette answered 8/3, 2017 at 15:16 Comment(1)
Welcome to StackOverflow! Here, you can learn How to Ask properly before you do so. When asking a question, be sure you are on topic and always try to provide a Minimal, Complete, and Verifiable example when possible. This way, it's more likely volunteers on SO can help you.Inconspicuous
V
1

This seems to work for me.

@media screen and (min-width: 1100px) {
    .wy-nav-side,
    .wy-grid-for-nav {
        margin-left: calc(((100vw - 1100px) / 2));
    }
    .wy-nav-content-wrap {
        background: none;
    }
    .wy-body-for-nav {
        background: rgba(0, 0, 0, 0.05);
    }
}
Violoncello answered 29/7, 2023 at 21:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.