0

I have Sphinx building documentation.

In source/conf.py I have

def setup(app):
    app.add_stylesheet('conduce-style.css')

in conduce-style.css

h1 {
   font-family: 'Gotham Ultra';
}

Then when it renders:

enter image description here

See how its using alabaster.css 's style for h1 and crossing out conduce-style.css's style? I want it to always prioritize my custom stylesheet over the theme's stylesheet. How can I do this in Sphinx?

mzjn
  • 48,958
  • 13
  • 128
  • 248
BigBoy1337
  • 4,735
  • 16
  • 70
  • 138

1 Answers1

1

CSS has rules of priority. You can try:

  • Use an equal or more specific CSS selector than alabaster's, e.g. div.body h1. More specific selector wins.
  • Slap !important at the end of your style (the sledgehammer approach).
  • Change the order in which style sheets are loading in the template theme (which would change the order in which individual styles are loaded, and the last loaded style wins).
Steve Piercy
  • 13,693
  • 1
  • 44
  • 57
  • any tips on how to do the third one? !important didn't seem to work. Is that something I do in the alabaster.css file? Or something in Sphinx's config.py? – BigBoy1337 Dec 02 '17 at 00:01
  • [See](https://stackoverflow.com/questions/33029008/how-to-edit-sidebar-under-sphinx-alabaster-theme/33057476#33057476) for example. – aflp91 Dec 02 '17 at 07:59