我一直在做這個游戲,你點擊鬼魂,它們就會消失。我不太擅長 JavaScript,找到了一種僅使用 CSS 來制作由按鈕觸發的影片的方法。問題是當我點擊幽靈時它消失了,但是當我再次點擊時幽靈又出現了。我認為這是因為我正在使用焦點,但我不確定。如果有一種方法可以在不使用 JavaScript 的情況下解決這個問題,那就太好了。
``` div {
text-align: center;
}
.ghost1 {
font-size: 14px;
border-radius: 50px;
border: none;
background-color: transparent;
}
.ghost2 {
font-size: 14px;
border-radius: 50px;
border: none;
background-color: transparent;
}
@keyframes ghost1 {
0% {
font-size: 14px;
}
100% {
font-size: 0px;
}
}
#btn1:focus {
animation-name: ghost1;
animation-duration: 0.2s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}
@keyframes ghost2 {
0% {
font-size: 14px;
}
100% {
font-size: 0px;
}
}
#btn2:focus {
animation-name: ghost2;
animation-duration: 0.2s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}
<button class="ghost1" id="btn1">??</button>
<button class="ghost2" id="btn2">??</button>
uj5u.com熱心網友回復:
我知道您不喜歡使用 javascript,但是您的 HTML 檔案中的一個簡單函式對我有用:
<body>
<button onclick="style.display = 'none'">
??
</button>
<button onclick="style.display = 'none'">
??
</button>
</body>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/315323.html
上一篇:在Ubuntu上的wxPython或其他GUI應用程式中,后端呼叫和執行的可視化
下一篇:CSS影片無法正常作業
