- HOME
- > BLOG CATEGORY
- 【CSS】transition-propertyの使い方、トランジション効果を適用させる

- お知らせ
- NEW 2023.06.01 【CSS】画像の透過について、mix-blend-modeを使ってみよう
- お知らせ
- 2023.05.18 【WordPress】各ページ背景画像の指定についてbody_classを解説
- お知らせ
- 2023.05.11 【WordPress】CPT UI インポート/エクスポート機能について解説
こんな方に読んでほしい
transition
プロパティについて学びたい方へ今回は、transitionに関する記事になります。
transitionトランジション効果とは、「時間的変化」の意味を持ちます。
transitionプロパティは、原則として「変化前のスタイル」に適用させます。
例として、「a」、「a:hover」があるとしたら、変化前である「a」の方に適用させます。
[記事の内容]
transition-property
プロパティとは、トランジション効果を適用させます。
書き方は以下のようになります。
/*--例:transition-property--*/
要素 a {
transition-property: 値;
}
要素 a:hover {
transition-property: 値;
}
propertyプロパティとは、変化を適用させる際に指定します。
プロパティ名とは、トランジション効果が適用するCSSのプロパティ名を指定します。
例として、背景色を変更したい場合は「background-color(背景色)」をプロパティ名として指定します。
カンマ(,)で区切りを入れ「color(文字色)」複数の指定をしています。
プロパティ名を指定
<a href="#" class="btn01">ボタン</a>
a.transition-btn {
padding: 20px 100px;
display: inline-block;
color: #333;
text-decoration :none;
text-align: center;
background-color: #ffbf4b;
/*--property background-color,colorを指定--*/
transition-property: background-color,color;
}
a.transition-btn:hover {
color: #fff;
text-decoration :none;
background-color: #fd5e5a;
}
上記では、プロパティ名での指定方法を解説しましたが、
基本、プロパティ名では、指定ぜず、「all」を使って指定します。
トランジション効果が適用できるすべてのプロパティを指定します。
まずは、プロパティ名でとallの指定方法の違いを確認しましょう。
/*--プロパティ名--*/
要素 a {
transition-property: background-color,color;
}
/*--all--*/
要素 a {
transition-property: all;
}
ポイント!
このように、プロパティ名では、複数のプロパティ名を指定しないといけませんが、
allを指定することで、すべてにトランジション効果が適用されます。
allを指定
<a href="#" class="btn01">ボタン</a>
a.btn01 {
padding: 20px 100px;
display: inline-block;
color: #333;
text-decoration :none;
text-align: center;
background-color: #ffbf4b;
/*--property allを指定--*/
transition-property: all;
}
a.btn01:hover {
color: #fff;
text-decoration :none;
background-color: #fd5e5a;
}
【STEP02 CSS】transition-timing-functionの使い方、効果の変化を適用させる
timing-functionプロパティとは、トランジション効果の変化(速度)のタイミングを適用させます。
【STEP03 CSS】transition-durationの使い方、効果が完了するまでの時間
transition-durationプロパティとは、トランジション効果が完了するまでの時間を指定します。
【STEP04 CSS】transition-delayの使い方、効果の開始時間を適用させる
transition-delayプロパティとは、トランジション効果が開始されるまでの時間を指定します。
【STEP05 CSS】トランジション効果(一括指定)について
transitionプロパティの一括指定について
今回はこれで以上です。
今回は、「property」プロパティについての解説になりましたが、その他にもトランジションの効果、時間
などがあります。
最終的には「transition」の一括指定まで覚えるようにしましょう。
次回は「トランジション効果の変化のタイミング」について解説します。
transition-property
プロパティとは、トランジション効果を適用させます。2023.06.01
2022.06.10
2022.06.03
2021.08.10
2023.06.01
2023.05.18
2023.05.11
2023.05.09
2023.05.04
2023.04.27
2022.06.30
2020.03.22
2020.03.06
2020.02.22
© 2020 shu-naka-blog