Skip to content

Commit a625fbd

Browse files
author
y-p
committed
DOC: modify theme css to keep navigation fixed on screen
1 parent 6b5ee26 commit a625fbd

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

doc/source/themes/nature_with_gtoc/layout.html

+24
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,28 @@ <h3 style="margin-top: 1.5em;">{{ _('Search') }}</h3>
6666
</div>
6767
</div>
6868
</div>
69+
70+
<script type="text/javascript">
71+
// http://movethewebforward.org/
72+
// paul irish et al. we <3 you.
73+
var $body = $( document.body );
74+
75+
var $scrollable = $(window); // default scrollable thingy, which'll be body or docEl (html)
76+
$originalnavtop =52; //$scrollable.css('top');
77+
78+
// work on scroll, but debounced
79+
var $document = $(document).scroll( function() {
80+
var $nav = $("div.sphinxsidebar");
81+
if($scrollable.scrollTop() > ($originalnavtop - 20)) {
82+
$nav.addClass('sticky').css('top', '0');
83+
$nav.addClass('sticky').css('position', 'fixed');
84+
} else {
85+
$nav.removeClass('sticky');
86+
$nav.addClass('sticky').css('position', '');
87+
$nav.addClass('sticky').css('top', '');
88+
}
89+
90+
});
91+
</script>
92+
6993
{%- endblock %}

doc/source/themes/nature_with_gtoc/static/nature.css_t

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ div.sphinxsidebar {
7979
width: {{ theme_sidebarwidth|toint }}px;
8080
margin: 0 ;
8181
float: left;
82-
82+
/*position: fixed;*/
8383
background-color: #eee;
8484
}
8585
/*

0 commit comments

Comments
 (0)