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

              
                <head>
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <!--==============Animate.cssのCDNを読み込み===============-->
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css">

  <!--==============レイアウトを制御する独自のCSSを読み込み===============-->
  <link href="https://assets.codepen.io/6329135/reset04.css" rel="stylesheet">
</head>

<body>
  <div class="wrapper">
    <p>↓ 画面が読み込まれたら現れる ↓ </p>
    <div class="box fadeUpTrigger">画面が読み込まれたらふわっ(下から)</div>
    <div class="box zoomInClickTrigger">クリックしたら1回だけ拡大</div>

    <!--画面が読み込まれたら現れる設定-->
    <div class="box fadeInUpTrigger">画面が読み込まれたら現れるボックス<br>画面が読み込まれたら、animate__animated animate__fadeInUpの2つのクラスが付与</div>

    <br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓
    <br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>スクロールすると出る<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓<br>↓

    <div class="box fadeUpTrigger">スクロールしたらふわっ(下から)</div>
    <div class="box zoomInClickTriggerTimes">クリックしたら何回も拡大</div>

    <!--スクロールをしたら現れる設定-->
    <div class="box fadeInUpTrigger">スクロールしたら現れるボックス<br>スクロールしたら、animate__animated animate__fadeInUpの2つのクラスが付与</div>

    <p class="btn">↓ ここをクリックしたら隠れているエリアが表示され、ボタン自体が消える ↓</p>
    <div class="hide_area">
      <p>このエリアが出現します。</p>
      <!--/wrapper-->
    </div>

    <script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
</body>
              
            
!

CSS

              
                @charset "utf-8";

/*==================================================
ふわっ
===================================*/
/* fadeUp */
.fadeUp {
  animation-name: fadeUpAnime;
  animation-duration: 0.5s;
  animation-fill-mode: forwards;
  opacity: 0;
}

@keyframes fadeUpAnime {
  from {
    opacity: 0;
    transform: translateY(100px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* スクロールをしたら出現する要素にはじめに透過0を指定 */
.fadeUpTrigger {
  opacity: 0;
}

/*==================================================
ぶわっ、ぽんっ
===================================*/

/* zoomIn */
.zoomIn {
  animation-name: zoomInAnime;
  animation-duration: 0.5s;
  animation-fill-mode: forwards;
}

@keyframes zoomInAnime {
  from {
    transform: scale(0.6);
  }

  to {
    transform: scale(1);
  }
}

/*========= クリックしたら別のものが動く際の指定 ===============*/

/*----ボタンの形状----*/

.btn {
  background: #333;
  cursor: pointer;
  padding: 10px 30px;
  color: #fff;
  text-align: center;
}

/*非表示エリアをはじめは隠す*/
.hide_area {
  display: none;
}

/*クリックされたら fadeUpクラスを付与し、display:block;で表示させる*/
.hide_area.fadeUp2 {
  display: block;
}

/* ボタンがクリックされた後にボタン自体が非表示になる */
.btn.disp_none {
  display: none;
}

/*==================================================
ふわっ2
===================================*/

/* fadeUp */

.fadeUp2 {
  animation-name: fadeUpAnime;
  animation-duration: 0.5s;
  animation-fill-mode: forwards;
  opacity: 0;
}

@keyframes fadeUpAnime {
  from {
    opacity: 0;
    transform: translateY(100px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fadeInUpTrigger {
  opacity: 0;
}

/*----クリックしたら別のものが動く際の指定----*/

.btn {
  background: #333;
  cursor: pointer;
  padding: 10px 30px;
  color: #fff;
  text-align: center;
}

/*非表示エリアをはじめは隠す*/
.hide_area {
  display: none;
}

/*クリックされたら animate__fadeInUpクラスを付与し、display:block;で表示させる*/
.hide_area.animate__fadeInUp {
  display: block;
}

/* ボタンがクリックされた後にボタン自体が非表示になる */
.btn.disp_none {
  display: none;
}

/*========= レイアウトのためのCSS ===============*/

body {
  vertical-align: middle;
  text-align: center;
  width: 100%;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-image: linear-gradient(
    100.6deg,
    rgba(218, 185, 252, 1) 22%,
    rgba(125, 89, 252, 1) 80%
  );
}

.wrapper {
  overflow: hidden;
  padding: 20px;
}

.flex {
  display: flex;
  flex-wrap: wrap;
  margin-top: 30px;
}

.box {
  width: fit-content;
  padding: 20px;
  margin: 20px 20px;
  color: #333;
  box-sizing: border-box;
  white-space: nowrap;

  background-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(6.5px);
  -webkit-backdrop-filter: blur(6.5px);

  box-shadow: 0px 6px 15px 0px rgba(142, 142, 142, 0.19);
  -webkit-box-shadow: 0px 6px 15px 0px rgba(142, 142, 142, 0.19);

  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 12px;
  -webkit-border-radius: 12px;
}

a {
  text-decoration: none;
  display: block;
}

.hide_area {
  padding: 100px 20px;
}

.clickpulseTrigger,
.zoomInClickTriggerTimes {
  cursor: pointer; /*カーソルを指マークに*/
}

              
            
!

JS

              
                // 動きのきっかけの起点となるアニメーションの名前を定義
function fadeAnime() {
  // ふわっ
  $(".fadeUpTrigger").each(function () {
    //fadeUpTriggerというクラス名が
    var elemPos = $(this).offset().top - 50; //要素より、50px上の
    var scroll = $(window).scrollTop();
    var windowHeight = $(window).height();
    if (scroll >= elemPos - windowHeight) {
      $(this).addClass("fadeUp"); // 画面内に入ったらfadeUpというクラス名を追記
    } else {
      $(this).removeClass("fadeUp"); // 画面外に出たらfadeUpというクラス名を外す
    }
  });
}

// 画面をスクロールをしたら動かしたい場合の記述
$(window).scroll(function () {
  fadeAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面をスクロールをしたら動かしたい場合の記述

// 画面が読み込まれたらすぐに動かしたい場合の記述
$(window).on("load", function () {
  fadeAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面が読み込まれたらすぐに動かしたい場合の記述

//要素やクラス名をクリックしたら動かしたい場合の記述
$(".zoomInClickTrigger").on("click", function () {
  $(this).addClass("zoomIn"); //要素をクリックしたらzoomInというクラス名を追記
});
//ここまで要素やクラス名をクリックしたら動かしたい場合の記述

//要素やクラス名をクリックしたら何度も動かしたい場合の記述
$(".zoomInClickTriggerTimes").on("click", function () {
  $(this).addClass("zoomIn"); //要素をクリックしたらzoomInというクラス名を追記
  $(".zoomIn").on("animationend", function () {
    $(this).removeClass("zoomIn"); //アニメーションが終了したらクラス名を取り除く
  });
});
//ここまで要素やクラス名をクリックしたら何度も動かしたい場合の記述

//要素やクラス名をクリックしたら動かしたい場合の記述

$(".btn").click(function () {
  // 動きのきっかけの起点となるクラス名がクリックされたら
  $(".hide_area").addClass("fadeUp2"); //隠れていた要素に動かしたいクラス名を付与
  $(this).addClass("disp_none"); //動きのきっかけの起点となるクラス名に画面非表示のクラス名付与
});

//ここまで要素やクラス名をクリックしたら動かしたい場合の記述

              
            
!
999px

Console