編輯演示是在這裏:http://3.cnxical.appspot.com具有不同效果的CSS動畫:懸停和:主動?
上懸停的text-shadow
性質的變化,並與animation-fill-mode
設置forwards
的狀態持續。
以下情況的動畫:active狀態不起作用,單擊標題時沒有任何反應。
預期的行爲是標題應該消失,因爲text-shadow
屬性設置爲(並且這兩者均已嘗試)none
或0 0 1px transparent
。設置text-shadow
爲:活動也嘗試沒有動畫,它不起作用。
如何才能實現正確的行爲?
的代碼是:
#title {
position:absolute;
cursor:pointer;
text-align:center;
top:15%;
left:50%;
-webkit-transform:translate(-50%,-50%);
color:transparent;
text-shadow:0 0 10px lime;
font-size:5vmin;
font-weight:bold;
font-family:"Courier New",Courier,monospace;
-webkit-animation: push_title_focus 0.3s;
}
#title:active {
-webkit-user-select:none;
-webkit-animation: vanish_title 0.3s;
}
#title:hover {
-webkit-animation: pull_title_focus 0.3s;
-webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes pull_title_focus {
from { text-shadow: 0 0 10px lime; }
to { text-shadow: 0 0 1px lime; }
}
@-webkit-keyframes push_title_focus {
from { text-shadow: 0 0 1px lime; }
to { text-shadow: 0 0 10px lime; }
}
@-webkit-keyframes vanish_title {
from { text-shadow: 0 0 1px lime; }
to { text-shadow: none !important; }
}
不應該是#title:專注於標題被點擊的時候嗎? –
我一直認爲焦點是標籤焦點,只是點擊時的副作用。主動是爲了點擊。你怎麼看? – Cris
我想我錯了 - 只是在小提琴中試過,它沒有奏效。但是,您現在有正確的答案:o) –