1/* Just add .fade-in class to element */
2
3.fade-in {
4 animation: fadeIn 2s;
5 opacity: 1;
6}
7
8@keyframes fadeIn {
9 from {
10 opacity: 0;
11 }
12 to {
13 opacity: 1;
14 }
15}
1/* Just add .fade-out class to element */
2
3.fade-out {
4 animation: fadeOut 2s;
5 opacity: 0;
6}
7
8@keyframes fadeOut {
9 from {
10 opacity: 1;
11 }
12 to {
13 opacity: 0;
14 }
15}
1/* Answer to: "css fade out" */
2
3/*
4 With the code below, all you have to do is use JavaScript to
5 give the element ".hide-opacity" and it'll fade-out.
6
7 Feel free to edit this code so it works on hover, focus, active
8 or any other special selector possible with CSS and of course
9 feel free to use this code with your JavaScript too!
10*/
11
12.successfully-saved {
13 color: #FFFFFF;
14 text-align: center;
15
16 -webkit-transition: opacity 3s ease-in-out;
17 -moz-transition: opacity 3s ease-in-out;
18 -ms-transition: opacity 3s ease-in-out;
19 -o-transition: opacity 3s ease-in-out;
20 opacity: 1;
21}
22
23.successfully-saved.hide-opacity {
24 opacity: 0;
25}
1<html>
2 <head>
3 <style>
4 .animated {
5 background-image: url(/css/images/logo.png);
6 background-repeat: no-repeat;
7 background-position: left top;
8 padding-top:95px;
9 margin-bottom:60px;
10 -webkit-animation-duration: 10s;animation-duration: 10s;
11 -webkit-animation-fill-mode: both;animation-fill-mode: both;
12 }
13
14 @-webkit-keyframes fadeOut {
15 0% {opacity: 1;}
16 100% {opacity: 0;}
17 }
18
19 @keyframes fadeOut {
20 0% {opacity: 1;}
21 100% {opacity: 0;}
22 }
23
24 .fadeOut {
25 -webkit-animation-name: fadeOut;
26 animation-name: fadeOut;
27 }
28 </style>
29 </head>
30
31 <body>
32
33 <div id = "animated-example" class = "animated fadeOut"></div>
34 <button onclick = "myFunction()">Reload page</button>
35
36 <script>
37 function myFunction() {
38 location.reload();
39 }
40 </script>
41
42 </body>
43</html>
44