1/* Answer to: "css transition opacity" */
2
3/*
4 CSS transitions allows you to change property values smoothly,
5 over a given duration.
6*/
7
8.myClass {
9 vertical-align: top;
10 transition: opacity 0.3s; /* Transition should take 0.3s */
11 -webkit-transition: opacity 0.3s; /* Transition should take 0.3s */
12 opacity: 1; /* Set opacity to 1 */
13}
14
15.myClass:hover {
16 opacity: 0.5; /* On hover, set opacity to 2 */
17}
18
19/*
20 From `opacity: 1;` to `opacity: 0.5;`, the transition time should
21 take 0.3 seconds as soon as the client starts to hover over the
22 element.
23*/
1<style>
2.myelement{
3 animation: fade-out;
4}
5
6@keyframes fade-out{
7 0%{
8 opacity: 1.0
9 }
10 100{
11 opacity: 0.0
12 }
13}
14</style>
1<style>
2 .element-class {
3 opacity: 0.5;
4 transition: opacity 0.5s ease-in-out;
5 }
6</style>