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

              
                <div class="scroll-indicator">
  <span>Scroll</span>
  <div class="arrow"></div>
</div>

<section id="section1">
  <h2>Section 1</h2>
  <p>Content of Section 1...</p>
</section>

<section id="section2">
  <h2>Section 2</h2>
  <p>Content of Section 2...</p>
</section>

<section id="section3">
  <h2>Section 3</h2>
  <p>Content of Section 3...</p>
</section>
              
            
!

CSS

              
                /* styles.css */

html {
  scroll-behavior: smooth;
}

body {
  font-family: Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

.scroll-indicator {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 1000;
  opacity: 1; /* 初期状態は表示 */
  transition: opacity 0.3s ease; /* フェードイン・アウトのアニメーション */
}

.scroll-indicator.hidden {
  opacity: 0; /* 非表示時は透明にする */
}

.scroll-indicator span {
  display: block;
  font-size: 24px;
  margin-bottom: 5px;
  color: #555; /* Scroll テキストの色 */
}

.arrow {
  width: 24px;
  height: 24px;
  border: solid #555; /* 矢印の色と太さ */
  border-width: 0 2px 2px 0; /* 矢印の形状 */
  transform: rotate(45deg); /* 矢印を反時計回りに45度回転 */
  margin: -10px auto 0;
  animation: arrowMove 1s infinite;
}

@keyframes arrowMove {
  0%, 100% {
    transform: translateY(0) rotate(45deg);
  }
  50% {
    transform: translateY(6px) rotate(45deg);
  }
}

section#section1 {
  height: 100vh; /* 高さをビューポートの高さに設定 */
  padding: 100px 20px;
  background-color: #f4f4f4;
}

section#section2 {
  background-color: aqua;
}

section#section3 {
  background-color: #f4f4f4;
}

section#section2,
section#section3 {
  height: 50vh; /* 高さをビューポートの高さに設定 */
  padding: 100px 20px;
}

section:nth-of-type(even) {
  background-color: #fff;
}

              
            
!

JS

              
                document.addEventListener("DOMContentLoaded", function() {
  var scrollIndicator = document.querySelector(".scroll-indicator");
  var section1 = document.querySelector("#section1");

  window.addEventListener("scroll", function() {
    var section1Bottom = section1.offsetTop + section1.offsetHeight;
    var scrollPosition = window.scrollY + window.innerHeight;

    // スクロール位置が #section1 の下にあれば、scrollIndicatorにhiddenクラスを追加する
    scrollIndicator.classList.toggle("hidden", scrollPosition > section1Bottom);
  });
});

              
            
!
999px

Console