A
animation屬性
關鍵字@keyframes用來定義一個動畫(簡單動畫--從某種長寬高旋轉傾斜等屬性在一定時間內內轉換到另一組對應屬性)
然后用animation屬性使用定義的動畫绩衷,寫法
animation:動畫名 完成一輪的時間 循環(huán)屬性
旋轉
div {
width: 150px;
height: 150px;
background-color: #6149ff;
}
@keyframes bigToSmall {
from {
transform: rotate(0deg);
/*width: 300px;*/
/*height: 300px;*/
}
to {
transform: rotate(360deg);
/*width: 150px;*/
/*height: 150px;*/
}
}
div:hover {
animation: bigToSmall 1s infinite;
}
變色
@keyframes colorChange {
from{
background-color: #6ffdff;
}
to{
background-color: #6149ff;
}
}
@keyframes colorChange
{
0% {background: #6ffdff;}
33.3% {background: #66B7FF;}
66.6% {background: #6149ff;}
100% {background: #A658FF;}
}
.a-2{
width: 150px;
height: 150px;
background-color: #6ffdff;
animation: colorChange 3s infinite;
}
B
animation屬性
關鍵字@keyframes用來定義一個動畫(簡單動畫--從某種長寬高旋轉傾斜等屬性在一定時間內內轉換到另一組對應屬性)
然后用animation屬性使用定義的動畫闲礼,寫法
animation:動畫名 完成一輪的時間 循環(huán)屬性
旋轉
div {
width: 150px;
height: 150px;
background-color: #6149ff;
}
@keyframes bigToSmall {
from {
transform: rotate(0deg);
/*width: 300px;*/
/*height: 300px;*/
}
to {
transform: rotate(360deg);
/*width: 150px;*/
/*height: 150px;*/
}
}
div:hover {
animation: bigToSmall 1s infinite;
}
變色
@keyframes colorChange {
from{
background-color: #6ffdff;
}
to{
background-color: #6149ff;
}
}
@keyframes colorChange
{
0% {background: #6ffdff;}
33.3% {background: #66B7FF;}
66.6% {background: #6149ff;}
100% {background: #A658FF;}
}
.a-2{
width: 150px;
height: 150px;
background-color: #6ffdff;
animation: colorChange 3s infinite;
}