<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous">
</script>
<style>@charset "utf-8";
/*========= スクロールダウンのためのCSS ===============*/
/*スクロールダウン全体の場所*/
.scrolldown {
/*描画位置※位置は適宜調整してください*/
position: absolute;
bottom: 10px;
right: 50%;
/*マウスの動き1.6秒かけて動く永遠にループ*/
animation: mousemove 1.6s ease-in-out infinite;
}
/*下からの距離が変化して上から下に動く*/
@keyframes mousemove {
0% {
bottom: 10px;
}
50% {
bottom: 5px;
}
100% {
bottom: 10px;
}
}
/*Scrollテキストの描写*/
.scrolldown span {
z-index: 10;
/*描画位置*/
position: absolute;
left: -15px;
bottom: 45px;
/*テキストの形状*/
color: #000;
font-size: 0.7rem;
letter-spacing: 0.05em;
white-space: nowrap;
}
/*マウスの中の線描写 */
.scrolldown span::after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
top: 10px;
left: 17px;
/*線の形状*/
width: 1px;
height: 15px;
background: #000;
/*線の動き1.4秒かけて動く。永遠にループ*/
animation: mousepathmove 1.4s linear infinite;
opacity: 0;
}
/*上からの距離・不透明度・高さが変化して上から下に流れる*/
@keyframes mousepathmove {
0% {
height: 0;
top: 10px;
opacity: 0;
}
50% {
height: 15px;
opacity: 1;
}
100% {
height: 0;
top: 30px;
opacity: 0;
}
}
/*マウスの描写 */
.scrolldown:before {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 0;
left: -10px;
/*マウスの形状*/
width: 25px;
height: 37px;
border-radius: 10px;
border: 1px solid #000;
}
/*マウスの中の丸の描写*/
.scrolldown:after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 26px;
left: 0;
/*丸の形状*/
width: 5px;
height: 5px;
border-radius: 50%;
border: 1px solid #000;
}
/*========= スクロールのためのCSS ===============*/
.space {
padding: 100vh 0;
}
/*========= レイアウトのためのCSS ===============*/
body {
background-image: linear-gradient(
68.4deg,
rgba(248, 182, 204, 1) 0.5%,
rgba(192, 198, 230, 1) 60%,
rgba(225, 246, 240, 1) 89.8%
);
}
p {
text-align: center;
padding: 20px 0;
font-size: 1.5rem;
letter-spacing: 0.5em;
word-break: break-all;
}
.TextTyping {
text-align: center;
}
/*========= タイピング ===============*/
.TextTyping span {
display: none;
}
/*文字列後ろの線の設定*/
.TextTyping::after {
content: "|";
animation: typinganime 0.8s ease infinite;
}
@keyframes typinganime {
from {
opacity: 0;
}
to {
opacity: 1;
}
}</style>
</head>
<body>
<body>
<div class="scrolldown">
<span>Scroll</span>
</div>
<p class="TextTyping">WEB先案内</p>
<p class="TextTyping">WebNavigator</p>
<div class="space">
</div>
<p class="TextTyping">WEB先案内</p>
<p class="TextTyping">WebNavigator</p>
<script>// TextTypingというクラス名がついている子要素(span)を表示から非表示にする定義
function TextTypingAnime() {
$(".TextTyping").each(function () {
var elemPos = $(this).offset().top - 50;
var scroll = $(window).scrollTop();
var windowHeight = $(window).height();
var thisChild = "";
if (scroll >= elemPos - windowHeight) {
thisChild = $(this).children(); //spanタグを取得
//spanタグの要素の1つ1つ処理を追加
thisChild.each(function (i) {
var time = 100;
//時差で表示する為にdelayを指定しその時間後にfadeInで表示させる
$(this).
delay(time * i).
fadeIn(time);
});
} else {
thisChild = $(this).children();
thisChild.each(function () {
$(this).stop(); //delay処理を止める
$(this).css("display", "none"); //spanタグ非表示
});
}
});
}
// 画面をスクロールをしたら動かしたい場合の記述
$(window).scroll(function () {
TextTypingAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面をスクロールをしたら動かしたい場合の記述
// 画面が読み込まれたらすぐに動かしたい場合の記述
$(window).on("load", function () {
//spanタグを追加する
var element = $(".TextTyping");
element.each(function () {
var text = $(this).html();
var textbox = "";
text.split("").forEach(function (t) {
if (t !== " ") {
textbox += "<span>" + t + "</span>";
} else {
textbox += t;
}
});
$(this).html(textbox);
});
TextTypingAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面が読み込まれたらすぐに動かしたい場合の記述
//# sourceURL=pen.js</script>
</body>
</html>
/*
外部依存 CSS:
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
外部依存 JS (このデモは下記の JS にも依存します):
- https://code.jquery.com/jquery-3.4.1.min.js
*/
@charset "utf-8";
/*========= スクロールダウンのためのCSS ===============*/
/*スクロールダウン全体の場所*/
.scrolldown {
/*描画位置※位置は適宜調整してください*/
position: absolute;
bottom: 10px;
right: 50%;
/*マウスの動き1.6秒かけて動く永遠にループ*/
animation: mousemove 1.6s ease-in-out infinite;
}
/*下からの距離が変化して上から下に動く*/
@keyframes mousemove {
0% {
bottom: 10px;
}
50% {
bottom: 5px;
}
100% {
bottom: 10px;
}
}
/*Scrollテキストの描写*/
.scrolldown span {
z-index: 10;
/*描画位置*/
position: absolute;
left: -15px;
bottom: 45px;
/*テキストの形状*/
color: #000;
font-size: 0.7rem;
letter-spacing: 0.05em;
white-space: nowrap;
}
/*マウスの中の線描写 */
.scrolldown span::after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
top: 10px;
left: 17px;
/*線の形状*/
width: 1px;
height: 15px;
background: #000;
/*線の動き1.4秒かけて動く。永遠にループ*/
animation: mousepathmove 1.4s linear infinite;
opacity: 0;
}
/*上からの距離・不透明度・高さが変化して上から下に流れる*/
@keyframes mousepathmove {
0% {
height: 0;
top: 10px;
opacity: 0;
}
50% {
height: 15px;
opacity: 1;
}
100% {
height: 0;
top: 30px;
opacity: 0;
}
}
/*マウスの描写 */
.scrolldown:before {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 0;
left: -10px;
/*マウスの形状*/
width: 25px;
height: 37px;
border-radius: 10px;
border: 1px solid #000;
}
/*マウスの中の丸の描写*/
.scrolldown:after {
z-index: 10;
content: "";
/*描画位置*/
position: absolute;
bottom: 26px;
left: 0;
/*丸の形状*/
width: 5px;
height: 5px;
border-radius: 50%;
border: 1px solid #000;
}
/*========= スクロールのためのCSS ===============*/
.space {
padding: 100vh 0;
}
/*========= レイアウトのためのCSS ===============*/
body {
background-image: linear-gradient(
68.4deg,
rgba(248, 182, 204, 1) 0.5%,
rgba(192, 198, 230, 1) 60%,
rgba(225, 246, 240, 1) 89.8%
);
}
p {
text-align: center;
padding: 20px 0;
font-size: 1.5rem;
letter-spacing: 0.5em;
word-break: break-all;
}
.TextTyping {
text-align: center;
}
/*========= タイピング ===============*/
.TextTyping span {
display: none;
}
/*文字列後ろの線の設定*/
.TextTyping::after {
content: "|";
animation: typinganime 0.8s ease infinite;
}
@keyframes typinganime {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/*
外部依存 JS:
- https://code.jquery.com/jquery-3.4.1.min.js
外部依存 CSS (このデモは下記の CSS にも依存します):
- https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css
*/
// TextTypingというクラス名がついている子要素(span)を表示から非表示にする定義
function TextTypingAnime() {
$(".TextTyping").each(function () {
var elemPos = $(this).offset().top - 50;
var scroll = $(window).scrollTop();
var windowHeight = $(window).height();
var thisChild = "";
if (scroll >= elemPos - windowHeight) {
thisChild = $(this).children(); //spanタグを取得
//spanタグの要素の1つ1つ処理を追加
thisChild.each(function (i) {
var time = 100;
//時差で表示する為にdelayを指定しその時間後にfadeInで表示させる
$(this).
delay(time * i).
fadeIn(time);
});
} else {
thisChild = $(this).children();
thisChild.each(function () {
$(this).stop(); //delay処理を止める
$(this).css("display", "none"); //spanタグ非表示
});
}
});
}
// 画面をスクロールをしたら動かしたい場合の記述
$(window).scroll(function () {
TextTypingAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面をスクロールをしたら動かしたい場合の記述
// 画面が読み込まれたらすぐに動かしたい場合の記述
$(window).on("load", function () {
//spanタグを追加する
var element = $(".TextTyping");
element.each(function () {
var text = $(this).html();
var textbox = "";
text.split("").forEach(function (t) {
if (t !== " ") {
textbox += "<span>" + t + "</span>";
} else {
textbox += t;
}
});
$(this).html(textbox);
});
TextTypingAnime(); /* アニメーション用の関数を呼ぶ*/
}); // ここまで画面が読み込まれたらすぐに動かしたい場合の記述
//# sourceURL=pen.js