Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <main class='main'>
  <nav class='nav'>
    <ul class='menu'>
      <li>menu1</li>
      <li>menu2</li>
      <li>menu3</li>
      <li>menu4</li>
    </ul>
  </nav>
  <section class='content'>
    What is Lorem Ipsum?
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </section>
  <footer class='footer'>The footer</footer>
  <!-- Scrolltop-->
  <div class="_torna_su" role="button" aria-label="Vai in alto">
    <div class="container_scroll_top" data-scroll="0"> <svg class="scroll-progress" width="80" height="80" viewPort="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg">
        <circle class="bg" r="33" cx="40" cy="40" fill="transparent" stroke-dasharray="264" stroke-dashoffset="0" />
        <circle class="progress" r="33" cx="40" cy="40" fill="transparent" stroke-dasharray="264" stroke-dashoffset="264" />
      </svg><object class="scroller_top"><span>T</span><span>O</span><span>R</span><span>N</span><span>A</span><span>&nbsp;</span><span>S</span><span>U</span><span>&nbsp;</span><span>T</span><span>O</span><span>R</span><span>N</span><span>A</span> <span>&nbsp;</span><span>S</span><span>U</span> <span>&nbsp;</span> </object> </div>
  </div>
  <!-- /Scrolltop-->
</main>
              
            
!

CSS

              
                body {
  margin: 0;
}

.nav {
  place-self: end;
  position: fixed;
  top: 0;
  background: rgb(0 0 0 / 40%);
  backdrop-filter: blur(10px);
}

.menu {
  display: flex;
  list-style: none;
}

.menu li {
  padding: 2rem;
}

.main,
.content,
.footer {
  display: flex;
  flex-direction: column;
  place-content: center center;
  align-items: center;
  width: 100%;
  height: auto;
}

.content {
  height: 150vh;
  background: lightgray;
}

.footer {
  background: blue;
  width: 100%;
  height: 30vh;
}

/*scrolltop should stay fixed*/
/*scrolltop*/
._torna_su {
  position: fixed;
  display: block;
  width: 80px;
  height: 80px;
  bottom: 8%;
  right: 1.2%;
  opacity: 0;
  z-index: 9999;
}
.container_scroll_top,
.scroller_top {
  position: relative;
  margin: auto;
  height: 80px;
  width: 80px;
}
.container_scroll_top:after {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  content: attr(data-scroll) "%";
  border-radius: 50%;
  color: #36383f;
  font-size: 1.2ch;
}
/*inner scrolltop*/
:is([data-scroll*="95"], [data-scroll*="96"], [data-scroll*="97"], [data-scroll*="98"], [data-scroll="99"], [data-scroll*="10"]:not([data-scroll$="10"]))
  span {
  font-weight: 900;
  color: red;
  -webkit-text-fill-color: red;
}
:is([data-scroll*="95"], [data-scroll*="96"], [data-scroll*="97"], [data-scroll*="98"], [data-scroll="99"], [data-scroll*="10"]:not([data-scroll$="10"])):after {
  transition: all 0.8s;
  opacity: 0;
  mix-blend-mode: difference;
}
.scroll-progress circle {
  stroke: #36383f;
  stroke-width: 0.5px;
}
.scroll-progress .progress {
  stroke-width: 0.5px;
  transition: 0.1s;
  stroke: #fff;
}
.scroller_top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
  color: #fff;
  border-radius: 50%;
  font-size: 0.5rem;
  --numero-lettere: 18;
  -webkit-text-fill-color: var(--text-color);
  backface-visibility: hidden;
}
.scroller_top span {
  --elem: 1;
  --rotazione: calc((1turn / var(--numero-lettere)) * var(--elem, 1));
  position: absolute;
  width: calc(100% - 2rem);
  height: calc(100% - 2rem);
  top: 1rem;
  left: 1rem;
  font-size: clamp(0.3rem, 5px, 0.9em);
  transform: rotate(var(--rotazione));
  transform-origin: center;
  will-change: tranform;
  transition: all 0.5s ease;
}
.scroller_top span:nth-child(2) {
  --elem: 2;
}
.scroller_top span:nth-child(3) {
  --elem: 3;
}
.scroller_top span:nth-child(4) {
  --elem: 4;
}
.scroller_top span:nth-child(5) {
  --elem: 5;
}
.scroller_top span:nth-child(6) {
  --elem: 6;
}
.scroller_top span:nth-child(7) {
  --elem: 7;
}
.scroller_top span:nth-child(8) {
  --elem: 8;
}
.scroller_top span:nth-child(9) {
  --elem: 9;
}
.scroller_top span:nth-child(10) {
  --elem: 10;
}
.scroller_top span:nth-child(11) {
  --elem: 11;
}
.scroller_top span:nth-child(12) {
  --elem: 12;
}
.scroller_top span:nth-child(13) {
  --elem: 13;
}
.scroller_top span:nth-child(14) {
  --elem: 14;
}
.scroller_top span:nth-child(15) {
  --elem: 15;
}
.scroller_top span:nth-child(16) {
  --elem: 16;
}
.scroller_top span:nth-child(17) {
  --elem: 17;
}
.scroller_top span:nth-child(18) {
  --elem: 18;
}
._torna_su:after {
  content: "";
  position: absolute;
  background: #fff;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  mix-blend-mode: difference;
  transform: scale(0);
  transform-origin: center center;
  transition: all 0.2s ease;
}
._torna_su:active:after {
  transform: scale(1);
}

              
            
!

JS

              
                /*SCROLL SMOOTHER*/
function smooth() {
  const smoother = ScrollSmoother.create({
    content: ".main",
    //wrapper:'.main-wrapper', //production ref
    smooth: 2,
    normalizeScroll: true,
    ignoreMobileResize: true,
    effects: true //future effets
  });
} //scrollsmoother init
smooth();

/*SCROLLTOP SHOULD STAY FIXED*/
function _scroll_to() {
  /*
 
  /*scrolltop*/
  /*test2*/
  !(function (e, t) {
    "object" == typeof exports && "undefined" != typeof module
      ? t(exports)
      : "function" == typeof define && define.amd
      ? define(["exports"], t)
      : t(((e = e || self).window = e.window || {}));
  })(this, function (e) {
    "use strict";
    function k() {
      return "undefined" != typeof window;
    }
    function l() {
      return u || (k() && (u = window.gsap) && u.registerPlugin && u);
    }
    function m(e) {
      return "string" == typeof e;
    }
    function n(e) {
      return "function" == typeof e;
    }
    function o(e, t) {
      var o = "x" === t ? "Width" : "Height",
        n = "scroll" + o,
        r = "client" + o;
      return e === T || e === i || e === c
        ? Math.max(i[n], c[n]) - (T["inner" + o] || i[r] || c[r])
        : e[n] - e["offset" + o];
    }
    function p(e, t) {
      var o = "scroll" + ("x" === t ? "Left" : "Top");
      return (
        e === T &&
          (null != e.pageXOffset
            ? (o = "page" + t.toUpperCase() + "Offset")
            : (e = null != i[o] ? i : c)),
        function () {
          return e[o];
        }
      );
    }
    function r(e, t) {
      if (!(e = f(e)[0]) || !e.getBoundingClientRect)
        return (
          console.warn("scrollTo target doesn't exist. Using 0") || {
            x: 0,
            y: 0
          }
        );
      var o = e.getBoundingClientRect(),
        n = !t || t === T || t === c,
        r = n
          ? {
              top:
                i.clientTop -
                (T.pageYOffset || i.scrollTop || c.scrollTop || 0),
              left:
                i.clientLeft -
                (T.pageXOffset || i.scrollLeft || c.scrollLeft || 0)
            }
          : t.getBoundingClientRect(),
        l = { x: o.left - r.left, y: o.top - r.top };
      return !n && t && ((l.x += p(t, "x")()), (l.y += p(t, "y")())), l;
    }
    function s(e, t, n, l, i) {
      return isNaN(e) || "object" == typeof e
        ? m(e) && "=" === e.charAt(1)
          ? parseFloat(e.substr(2)) * ("-" === e.charAt(0) ? -1 : 1) + l - i
          : "max" === e
          ? o(t, n) - i
          : Math.min(o(t, n), r(e, t)[n] - i)
        : parseFloat(e) - i;
    }
    function t() {
      (u = l()),
        k() &&
          u &&
          document.body &&
          ((T = window),
          (c = document.body),
          (i = document.documentElement),
          (f = u.utils.toArray),
          u.config({ autoKillThreshold: 7 }),
          (v = u.config()),
          (a = 1));
    }
    var u,
      a,
      T,
      i,
      c,
      f,
      v,
      y = {
        version: "3.10.2",
        name: "scrollTo",
        rawVars: 1,
        register: function register(e) {
          (u = e), t();
        },
        init: function init(e, o, r, l, i) {
          a || t();
          var c = this,
            f = u.getProperty(e, "scrollSnapType");
          (c.isWin = e === T),
            (c.target = e),
            (c.tween = r),
            (o = (function _clean(e, t, o, r) {
              if ((n(e) && (e = e(t, o, r)), "object" != typeof e))
                return m(e) && "max" !== e && "=" !== e.charAt(1)
                  ? { x: e, y: e }
                  : { y: e };
              if (e.nodeType) return { y: e, x: e };
              var l,
                i = {};
              for (l in e)
                i[l] = "onAutoKill" !== l && n(e[l]) ? e[l](t, o, r) : e[l];
              return i;
            })(o, l, e, i)),
            (c.vars = o),
            (c.autoKill = !!o.autoKill),
            (c.getX = p(e, "x")),
            (c.getY = p(e, "y")),
            (c.x = c.xPrev = c.getX()),
            (c.y = c.yPrev = c.getY()),
            f &&
              "none" !== f &&
              ((c.snap = 1),
              (c.snapInline = e.style.scrollSnapType),
              (e.style.scrollSnapType = "none")),
            null != o.x
              ? (c.add(c, "x", c.x, s(o.x, e, "x", c.x, o.offsetX || 0), l, i),
                c._props.push("scrollTo_x"))
              : (c.skipX = 1),
            null != o.y
              ? (c.add(c, "y", c.y, s(o.y, e, "y", c.y, o.offsetY || 0), l, i),
                c._props.push("scrollTo_y"))
              : (c.skipY = 1);
        },
        render: function render(e, t) {
          for (
            var n,
              r,
              l,
              i,
              s,
              p = t._pt,
              c = t.target,
              f = t.tween,
              u = t.autoKill,
              a = t.xPrev,
              y = t.yPrev,
              d = t.isWin,
              x = t.snap,
              g = t.snapInline;
            p;

          )
            p.r(e, p.d), (p = p._next);
          (n = d || !t.skipX ? t.getX() : a),
            (l = (r = d || !t.skipY ? t.getY() : y) - y),
            (i = n - a),
            (s = v.autoKillThreshold),
            t.x < 0 && (t.x = 0),
            t.y < 0 && (t.y = 0),
            u &&
              (!t.skipX && (s < i || i < -s) && n < o(c, "x") && (t.skipX = 1),
              !t.skipY && (s < l || l < -s) && r < o(c, "y") && (t.skipY = 1),
              t.skipX &&
                t.skipY &&
                (f.kill(),
                t.vars.onAutoKill &&
                  t.vars.onAutoKill.apply(f, t.vars.onAutoKillParams || []))),
            d
              ? T.scrollTo(t.skipX ? n : t.x, t.skipY ? r : t.y)
              : (t.skipY || (c.scrollTop = t.y),
                t.skipX || (c.scrollLeft = t.x)),
            !x ||
              (1 !== e && 0 !== e) ||
              ((r = c.scrollTop),
              (n = c.scrollLeft),
              g
                ? (c.style.scrollSnapType = g)
                : c.style.removeProperty("scroll-snap-type"),
              (c.scrollTop = r + 1),
              (c.scrollLeft = n + 1),
              (c.scrollTop = r),
              (c.scrollLeft = n)),
            (t.xPrev = t.x),
            (t.yPrev = t.y);
        },
        kill: function kill(e) {
          var t = "scrollTo" === e;
          (!t && "scrollTo_x" !== e) || (this.skipX = 1),
            (!t && "scrollTo_y" !== e) || (this.skipY = 1);
        }
      };
    (y.max = o),
      (y.getOffset = r),
      (y.buildGetter = p),
      l() && u.registerPlugin(y),
      (e.ScrollToPlugin = y),
      (e.default = y);
    if (typeof window === "undefined" || window !== e) {
      Object.defineProperty(e, "__esModule", { value: !0 });
    } else {
      delete e.default;
    }
  });
  /*test2*/
  (function () {
    let a = document.querySelector("._torna_su");
    if (a) {
      function b() {
        let a = document.body.scrollTop || document.documentElement.scrollTop,
          b =
            document.documentElement.scrollHeight -
            document.documentElement.clientHeight,
          e = Math.floor(100 * (a / b));
        d.setAttribute("data-scroll", e),
          (c.style.strokeDashoffset = 264 - 264 * (e / 100));
      }
      let c = document.querySelector(".progress"),
        d = document.querySelector(".container_scroll_top");
      window.onscroll = function () {
        b();
      };
      let e = gsap.timeline({
        scrollTrigger: {
          start: "center center",
          end: "max",
          scrub: !0,
          pinReparent: true,
          pinSpacing: false
        }
      });
      e
        .fromTo(
          a,
          { autoAlpha: 0 },
          { autoAlpha: 1, pointerEvents: "auto", duration: 0.3 }
        )
        .to(".scroller_top", {
          rotate: 360,
          ease: "none",
          scrollTrigger: { scrub: 0.1 }
        }),
        a.addEventListener("click", () => {
          gsap.to(window, { scrollTo: { y: 0, autoKill: !1 } });
        });
    }
  })();
} //chiudi gsap scrollto
_scroll_to();

              
            
!
999px

Console