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

              
                <p class="bottom_text">⇩</p>
<p class="bottom_text">⇩</p>
<p class="bottom_text">⇩</p>
<footer>
	<p id="page_top"><a href="#">TOP</a></p>
</footer>
              
            
!

CSS

              
                .bottom_text {text-align:center;font-size:150px;}
a:hover{opacity: 0.6;}
/*------------------------------------
topに戻るボタン
------------------------------------*/
#page_top {
  position: fixed;
  transform: translateY(100px);
}
#page_top a {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #3b5d82;
  border-radius: 50%;
  color: #fff;
  text-decoration: none;
  transition: all 0.3s;
}
#page_top.upmove {
  animation: UpAnime 0.5s forwards;
}
@keyframes UpAnime {
  from {
    opacity: 0;
    transform: translateY(100px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
#page_top.downmove {
  animation: DownAnime 0.5s forwards;
}
@keyframes DownAnime {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 1;
    transform: translateY(100px);
  }
}
/* @media (min-width: 1000px) {} 1000px以上で適用 */
@media (min-width: 1000px) {
  /*  ボタン配置  */
  #page_top {
    right: 24px; 
    bottom: 0;
  }
  #page_top a {
    width: 80px;
    height: 80px;
  }
}
/* @media (max-width: 999px) {} 999px以下で適用 */
@media (max-width: 999px) {
  #page_top {
    right: 12px;
    bottom: 0;
  }
  #page_top a {
    width: 50px;
    height: 50px;
    font-size: 0.6rem;
  }
}
              
            
!

JS

              
                //topに戻るボタン
function topanime() {
  var scroll = $(window).scrollTop();
  //50pxスクロールしたらpage_topが出てくる
  if (scroll >= 50) {
    $("#page_top").removeClass("downmove"); //初期クラス名
    $("#page_top").addClass("upmove"); //クラス名追加
  } else {
    if ($("#page_top").hasClass("upmove")) { //classが存在するかを確認
      $("#page_top").removeClass("upmove"); //pagetopの場合はクラス名削除
      $("#page_top").addClass("downmove"); //pagetopの場合はクラス名追加
    }
  }
}
$(window).scroll(function () {
  topanime();
});
$(window).on("load", function () {
  topanime();
});
$("#page_top a").click(function () {
  $("body,html").animate(
    {
      scrollTop: 0,
    },
   500 //スクロールスピード
  );
  return false;
});
              
            
!
999px

Console