HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
@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; /*カーソルを指マークに*/
}
// 動きのきっかけの起点となるアニメーションの名前を定義
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"); //動きのきっかけの起点となるクラス名に画面非表示のクラス名付与
});
//ここまで要素やクラス名をクリックしたら動かしたい場合の記述
Also see: Tab Triggers