浏览代码

Fix search bar shadow when it's not fixed due to scrolling yet

This closes #3113.
Hugo Locurcio 5 年之前
父节点
当前提交
36b76ba70a
共有 2 个文件被更改,包括 7 次插入3 次删除
  1. 5 1
      _static/css/custom.css
  2. 2 2
      _static/js/custom.js

+ 5 - 1
_static/css/custom.css

@@ -422,10 +422,14 @@ code,
     background-color: var(--navbar-background-color);
     background-color: var(--navbar-background-color);
 }
 }
 
 
+.wy-side-nav-search.fixed {
+    position: fixed;
+}
+
 @media only screen and (min-width: 768px) {
 @media only screen and (min-width: 768px) {
     /* Simulate a drop shadow that only affects the bottom edge */
     /* Simulate a drop shadow that only affects the bottom edge */
     /* This is used to indicate the search bar is fixed */
     /* This is used to indicate the search bar is fixed */
-    .wy-side-nav-search::after {
+    .wy-side-nav-search.fixed::after {
         content: '';
         content: '';
         position: absolute;
         position: absolute;
         left: 0;
         left: 0;

+ 2 - 2
_static/js/custom.js

@@ -25,11 +25,11 @@ function registerOnScrollEvent(mediaQuery) {
     $navbar.scroll(function() {
     $navbar.scroll(function() {
       if ($(this).scrollTop() >= scrollTopPixels) {
       if ($(this).scrollTop() >= scrollTopPixels) {
         $logo.hide();
         $logo.hide();
-        $search.css('position', 'fixed');
+        $search.addClass('fixed');
         $menu.css('margin-top', menuTopMargin);
         $menu.css('margin-top', menuTopMargin);
       } else {
       } else {
         $logo.show();
         $logo.show();
-        $search.css('position', 'static');
+        $search.removeClass('fixed');
         $menu.css('margin-top', 0);
         $menu.css('margin-top', 0);
       }
       }
     });
     });