浏览代码

fix anchor links

Artur Paikin 6 年之前
父节点
当前提交
a9b7b3d5b3

+ 4 - 3
website/themes/uppy/source/css/_common.scss

@@ -239,11 +239,12 @@ a.button {
     // position: relative;
     z-index: 2;
     border-top: 3px solid $color-primary;
+    border-bottom: 1px solid rgba($color-lightgray, 0.3);
     text-align: left;
 
-    &.fix-header {
-      box-shadow: 0 0 4px rgba(0,0,0,.25);
-    }
+    // &.fix-header {
+    //   box-shadow: 0 0 4px rgba(0,0,0,.25);
+    // }
   }
 }
 

+ 23 - 3
website/themes/uppy/source/css/_page.scss

@@ -32,11 +32,13 @@
   @media #{$screen-medium} {
     // position: absolute;
     top: 60px;
-    left: 60px;
+    left: 0;
     // bottom: 0;
-    padding: 2.2em 0;
+    // padding: 2.2em 0;
+    padding-top: 35px;
+    padding-left: 60px;
     padding-bottom: 130px;
-    width: 230px;
+    // width: 20px;
     margin-right: 20px;
     overflow-x: hidden;
     overflow-y: auto;
@@ -169,6 +171,24 @@
     margin-left: 20px;
   }
 
+  // h2, h3 {
+  //   padding-top: 80px;
+  // }
+
+  // for ancor links to work with fixed header
+  h2:before, h3:before {
+    content: '';
+    display: block;
+    margin-top: -60px;
+    height: 60px;
+    visibility: hidden;
+
+    @media #{$screen-large} {
+      margin-top: -90px;
+      height: 90px;
+    }
+  }
+
   .post h1,
   > h1 {
     font-size: 1.6em;

+ 9 - 9
website/themes/uppy/source/js/common.js

@@ -23,9 +23,9 @@
     var animating = false
     var allLinks = []
 
-    // listen for scroll event to do positioning & highlights
-    window.addEventListener('scroll', updateSidebar)
-    window.addEventListener('resize', updateSidebar)
+    // // listen for scroll event to do positioning & highlights
+    // window.addEventListener('scroll', updateSidebar)
+    // window.addEventListener('resize', updateSidebar)
 
     function updateSidebar () {
       var top = (doc && doc.scrollTop) || body.scrollTop
@@ -178,16 +178,16 @@
 
         // init smooth scroll
         window.smoothScroll.init({
-          speed: 400,
-          offset: window.innerWidth > 720
-            ? 40
-            : 58
+          speed: 400
+          // offset: window.innerWidth > 720
+          //   ? 40
+          //   : 58
         })
       }
 
       // listen for scroll event to do positioning & highlights
-      // window.addEventListener('scroll', updateSidebar)
-      // window.addEventListener('resize', updateSidebar)
+      window.addEventListener('scroll', updateSidebar)
+      window.addEventListener('resize', updateSidebar)
     }
 
     var isBlog = menu.classList.contains('is-blog')