טוב אז לפני שנתחיל לפי דעתי CSS3 כבר מחליף את JQ (:
אז נתחיל
-------------------------
שלום לכולם, כאן עדן והיום אני רוצה ללמד אתכם כיצד להכין קוד פשוט בCSS3 של אנמצית החלפת צבעים עם פאדים.
או-קיי.
אז נתחיל.
הקוד הראשי הוא :
קוד:
<!DOCTYPE html>
<html>
<head>
<style>
div
{
width:100px;
height:100px;
background:red;
animation:myfirst 5s;
-moz-animation:myfirst 5s; /* Firefox */
-webkit-animation:myfirst 5s; /* Safari and Chrome */
-o-animation:myfirst 5s; /* Opera */
}
@keyframes myfirst
{
from {background:red;}
to {background:yellow;}
}
@-moz-keyframes myfirst /* Firefox */
{
from {background:red;}
to {background:yellow;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
from {background:red;}
to {background:yellow;}
}
@-o-keyframes myfirst /* Opera */
{
from {background:red;}
to {background:yellow;}
}
</style>
</head>
<body>
<p><b>Note:</b> This example does not work in Internet Explorer.</p>
<div></div>
</body>
</html>
אז נתחיל להסביר,
קוד:
width:100px;
height:100px;
background:red;
animation:myfirst 5s;
-moz-animation:myfirst 5s; /* Firefox */
-webkit-animation:myfirst 5s; /* Safari and Chrome */
-o-animation:myfirst 5s; /* Opera */
}
כאן הגדרנו את הריבוע שרצינו , הגודל שלו , הרוחב שלו , התאמה לכל הדפדפנים וכ'.
קוד:
@keyframes myfirst
{
0% {background:red;}
25% {background:yellow;}
50% {background:blue;}
100% {background:green;}
}
כאן הגרדנו 4 צבעים שיתחלפו באמצע האנמציה.
קוד:
@-moz-keyframes myfirst /* Firefox */
{
0% {background:red;}
25% {background:yellow;}
50% {background:blue;}
100% {background:green;}
}
@-webkit-keyframes myfirst /* Safari and Chrome */
{
0% {background:red;}
25% {background:yellow;}
50% {background:blue;}
100% {background:green;}
}
@-o-keyframes myfirst /* Opera */
{
0% {background:red;}
25% {background:yellow;}
50% {background:blue;}
100% {background:green;}
}
והינה כל השאר, אותו דבר רק התאמה לכל הדפדפנים חוץ מאקספלורר.
מקווה שהבנתם , הפנתם ותוכלו להשתמש בזה בעתיד - בהצלחה לכולם!