-
Notifications
You must be signed in to change notification settings - Fork 0
CSS Animation の資料を追加 #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| ```css | ||
| .nav { | ||
| animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cubic-bezierが初見なので、解説を追加すると良さそう。
FYI
https://cubic-bezier.com/#.4,0,.2,1 でベジェ曲線の可視化をしてくれるらしいです。(claude code先輩が伝えてきた)
資料下部に書いてありましたね 🙇
アラート記法とかで案内しても良いかもです。
https://qiita.com/Yarakashi_Kikohshi/items/e6802e08921388d8c6e9
| ## 🎨 cubic-bezier() について | ||
|
|
||
| `cubic-bezier()` はアニメーションのイージング(加速・減速)を制御する関数です。 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 次ベジェ曲線を使用してスムーズな遷移を作成します。
MDNより、↑の説明を追加してもよいかも?ベジエ曲線というワードを入れたほうが「イメージしやすいかも?」と思いました。
https://developer.mozilla.org/ja/docs/Web/CSS/Reference/Values/easing-function/cubic-bezier
|
|
||
| ## 📚 学習ステップ | ||
|
|
||
| ### Step 1: 基本的な @keyframes アニメーション |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
Step1では、動きを定義するだけ実際には動かない。
- ここの授業するときの、説明の仕方は考えておくと良さそう。(というより、シミュレーションみたいなイメージ)
| .nav-menu a::after { | ||
| transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
ホーバー時に下線を表示するCSSがstyle.cssにある。
- ここでは、それを制御した形。
| #### 2-4. テーマ切替ボタンのホバー | ||
|
|
||
| ```css | ||
| .theme-toggle { | ||
| transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); | ||
| } | ||
|
|
||
| .theme-toggle:hover { | ||
| background: var(--color-accent); | ||
| border-color: var(--color-accent); | ||
| transform: rotate(180deg); | ||
| } | ||
|
|
||
| .theme-toggle:hover svg { | ||
| stroke: white; | ||
| } | ||
|
|
||
| .theme-toggle svg { | ||
| transition: stroke 0.15s cubic-bezier(0.4, 0, 0.2, 1); | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
- 冒頭でallを指定→全部の要素にtransitonがつくはず。
- svg側はtransitonを上書きしているけど。
- strokeは svgの線の色の指定をするときに使うらしい。
- ※時間があったら、ここでsvg側の秒数を変える遊びをしてもいいかも?(この要素にこだわっているわけではないけど)
| .theme-toggle:hover { | ||
| background: var(--color-accent); | ||
| border-color: var(--color-accent); | ||
| transform: rotate(180deg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
rotateはここが初登場
| **確認方法:** 右上のテーマ切替ボタンにマウスをホバーすると回転します。 | ||
|
|
||
| ### Step 3: ヒーローセクションのアニメーション |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- @media とかで詰まるかも?
- 📝 active が押したときに動作するやつ
- スマホ用に「開発者ツール」で縮める説明が必要なので、スキップでも良さそう。
|
※ 📝 には、自分が瞬間的には理解できなかったものを書き綴っています🙏 |
| ```css | ||
| .typing-text { | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .typing-text .title-line { | ||
| display: block; | ||
| opacity: 0; | ||
| animation: typing-reveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
- 詰まった所
- overflow:hidden はアニメーションとは関係なさそう
- forwardsが初見
- nth-child は番号がついているので、なんとなく察した。
- →みたいな予想を毎回してもらうと良いかも?(時間があれば)
claude解説
1. 親要素(.typing-text)
.typing-text {
overflow: hidden; /* はみ出た部分を隠す */
}
2. 各行の基本設定(.title-line)
.typing-text .title-line {
display: block; /* ブロック要素として表示 */
opacity: 0; /* 初期状態は透明(見えない) */
animation: typing-reveal 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
animation の構成:
typing-reveal: アニメーション名([animations.css:46-56](vscode-webview://0hav65pjflksd562ul60i5bn3odr6l8ekfn180ircqimktc0f2tj/2025/css-animation/animations.css#L46-L56)で定義)
0.8s: 0.8秒かけて実行
cubic-bezier(0.4, 0, 0.2, 1): イージング関数
forwards: アニメーション終了後、最終状態を維持
| } | ||
|
|
||
| .typing-text .title-line { | ||
| display: block; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| .scroll-arrow { | ||
| animation: bounce 2s ease-in-out infinite; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
ease-in-out infiniteが初見
| .btn::before { | ||
| content: ''; | ||
| position: absolute; | ||
| top: 50%; | ||
| left: 50%; | ||
| width: 0; | ||
| height: 0; | ||
| border-radius: 50%; | ||
| background: rgba(255, 255, 255, 0.2); | ||
| transform: translate(-50%, -50%); | ||
| transition: width 0.6s, height 0.6s; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
- (親起点で)absolute
- そのうえで位置指定(中心に配置)
border-radius: 50%で丸なのはわかってた。transform: translate(-50%, -50%);で要素自体を真ん中に持ってくる (なるほど)active::beforeと比較すると前段階の::beforeに設置する。(よく考えたら他と一緒だけど、疑似要素がついているから一瞬混乱した)
| --color-accent: #3b82f6; | ||
| --color-accent-hover: #2563eb; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #### 6-3. リンクのアンダーラインアニメーション | ||
|
|
||
| ```css | ||
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
- 長いCSS👀
- aタグにこの5つのクラスがある場合は無視するってやつ。
まぁ、質問来たらでいいかな。。。
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo) { | ||
| /* position: relative; */ | ||
| } | ||
|
|
||
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo)::after { | ||
| /* content: ''; | ||
| position: absolute; | ||
| bottom: -2px; | ||
| left: 0; | ||
| width: 0; | ||
| height: 1px; | ||
| background: currentColor; | ||
| transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); */ | ||
| } | ||
|
|
||
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo):hover::after { | ||
| /* width: 100%; */ | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo) { | |
| /* position: relative; */ | |
| } | |
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo)::after { | |
| /* content: ''; | |
| position: absolute; | |
| bottom: -2px; | |
| left: 0; | |
| width: 0; | |
| height: 1px; | |
| background: currentColor; | |
| transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); */ | |
| } | |
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo):hover::after { | |
| /* width: 100%; */ | |
| } | |
| a:not(.btn, .card-link-wrapper, .social-link, .social-link-large, .nav-logo) { | |
| position: relative; | |
| } | |
| a:not(.btn, .card-link-wrapper, .social-link, .social-link-large, .nav-logo)::after { | |
| content: ''; | |
| position: absolute; | |
| bottom: -2px; | |
| left: 0; | |
| width: 0; | |
| height: 1px; | |
| background: currentColor; | |
| transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1); | |
| } | |
| a:not(.btn, .card-link-wrapper, .social-link, .social-link-large, .nav-logo):hover::after { | |
| width: 100%; | |
| } |
| /* position: relative; */ | ||
| } | ||
|
|
||
| a:not(.btn):not(.card-link-wrapper):not(.social-link):not(.social-link-large):not(.nav-logo)::after { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
- このタイミングで「aタグ」と「a:after」が別要素なので、positonがそれぞれ違くても良いということを理解した。
|
|
||
| ### Step 7: スクロールアニメーション | ||
|
|
||
| `.fade-in-on-scroll`、`.slide-in-left-on-scroll`、`.slide-in-right-on-scroll`、`.scale-in-on-scroll` クラスは、 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /* コメントを外すと、アバター画像にマウスホバーしたときに拡大・回転します */ | ||
| .avatar-large, | ||
| .author-avatar { | ||
| /* transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); */ | ||
| } | ||
|
|
||
| .avatar-large:hover { | ||
| /* transform: scale(1.05) rotate(5deg); */ | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| .skill-item:nth-child(1) .skill-progress { | ||
| --progress: 95%; | ||
| /* animation-delay: 0.1s; */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
草
- animation-delayで0.1sずつずらす、というパワープレイ 😂
| .timeline-marker { | ||
| /* animation: scale-pulse 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); */ | ||
| } | ||
|
|
||
| .timeline-article-marker { | ||
| /* animation: scale-pulse 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55); */ | ||
| } | ||
|
|
||
| @keyframes scale-pulse { | ||
| /* 0% { | ||
| transform: scale(0); | ||
| } | ||
| 50% { | ||
| transform: scale(1.2); | ||
| } | ||
| 100% { | ||
| transform: scale(1); | ||
| } */ | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| /* 11-1. スクロールプログレスバー */ | ||
| /* コメントを外すと、ページをスクロールしたときに進捗バーが伸びます */ | ||
| @supports (animation-timeline: scroll()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
@supports (animation-timeline: scroll())はブラウザが引数のやつを使用可能なときだけ、適応するというやつらしい。
| window.categoryFilter = new CategoryFilter(); | ||
|
|
||
| new ScrollAnimationObserver(); | ||
| new ScrollProgress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| ```css | ||
| @supports (animation-timeline: scroll()) { | ||
| /* 背景画像:ゆっくり動く(遠くにあるように見える) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @supports (animation-timeline: scroll()) { | ||
| /* 背景画像:ゆっくり動く(遠くにあるように見える) */ | ||
| .parallax-image { | ||
| animation: parallax-bg linear; | ||
| animation-timeline: scroll(root); | ||
| animation-range: 0 600px; | ||
| } | ||
|
|
||
| @keyframes parallax-bg { | ||
| to { | ||
| transform: translateY(100px); | ||
| } | ||
| } | ||
|
|
||
| /* 装飾円1:速く動く(手前にあるように見える) */ | ||
| .parallax-circle-1 { | ||
| animation: parallax-fast linear; | ||
| animation-timeline: scroll(root); | ||
| animation-range: 0 600px; | ||
| } | ||
|
|
||
| @keyframes parallax-fast { | ||
| to { | ||
| transform: translateY(300px); | ||
| } | ||
| } | ||
|
|
||
| /* 装飾円2:中くらいの速度で動く */ | ||
| .parallax-circle-2 { | ||
| animation: parallax-medium linear; | ||
| animation-timeline: scroll(root); | ||
| animation-range: 0 600px; | ||
| } | ||
|
|
||
| @keyframes parallax-medium { | ||
| to { | ||
| transform: translateY(200px); | ||
| } | ||
| } | ||
|
|
||
| /* 装飾円3:とても速く動く(最も手前にあるように見える) */ | ||
| .parallax-circle-3 { | ||
| animation: parallax-very-fast linear; | ||
| animation-timeline: scroll(root); | ||
| animation-range: 0 600px; | ||
| } | ||
|
|
||
| @keyframes parallax-very-fast { | ||
| to { | ||
| transform: translateY(400px); | ||
| } | ||
| } | ||
|
|
||
| /* 四角形:回転しながら動く */ | ||
| .parallax-square { | ||
| animation: parallax-rotate linear; | ||
| animation-timeline: scroll(root); | ||
| animation-range: 0 600px; | ||
| } | ||
|
|
||
| @keyframes parallax-rotate { | ||
| to { | ||
| transform: translateY(250px) rotate(225deg); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝
個人的には、この部分が視覚効果として感動しました!
|
@takerucam |

html, css, js のファイルを追加しました。
README を見ながら進めてもらい不備がないかのチェックをしていただきたいです。