From 36b76ba70a128951368a3a2d56d8c05d4f00398c Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 29 Jan 2020 01:47:02 +0100 Subject: [PATCH] Fix search bar shadow when it's not fixed due to scrolling yet This closes #3113. --- _static/css/custom.css | 6 +++++- _static/js/custom.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/_static/css/custom.css b/_static/css/custom.css index 36e2db3c9..11e108701 100644 --- a/_static/css/custom.css +++ b/_static/css/custom.css @@ -422,10 +422,14 @@ code, background-color: var(--navbar-background-color); } +.wy-side-nav-search.fixed { + position: fixed; +} + @media only screen and (min-width: 768px) { /* Simulate a drop shadow that only affects the bottom edge */ /* This is used to indicate the search bar is fixed */ - .wy-side-nav-search::after { + .wy-side-nav-search.fixed::after { content: ''; position: absolute; left: 0; diff --git a/_static/js/custom.js b/_static/js/custom.js index 0391a088d..7f05c9577 100644 --- a/_static/js/custom.js +++ b/_static/js/custom.js @@ -25,11 +25,11 @@ function registerOnScrollEvent(mediaQuery) { $navbar.scroll(function() { if ($(this).scrollTop() >= scrollTopPixels) { $logo.hide(); - $search.css('position', 'fixed'); + $search.addClass('fixed'); $menu.css('margin-top', menuTopMargin); } else { $logo.show(); - $search.css('position', 'static'); + $search.removeClass('fixed'); $menu.css('margin-top', 0); } });