Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
66 views
in Technique[技术] by (71.8m points)

Can I run animation with css button?

When I click on a button that I have given, I want the button to activate the animation, but I have two animations when I add both, I get an error, how can I solve it :) I'm doing this animation for dark mode transition effect

#drk:active .turtle {
    animation: drag 4s linear;
   -webkit-animation: drag 4s linear alternate; /* Chrome and Safari */
  
   
    height: 100%;
    position: fixed;
    z-index: 50;
    top:0px;
    left: 0px;
  }

#drk:active . {
    animation: drag 4s linear;
   -webkit-animation: drag 4s linear alternate; /* Chrome and Safari */
  
   
    height: 100%;
    position: fixed;
    z-index: 50;
    top:0px;
    left: 0px;
  }
question from:https://stackoverflow.com/questions/65841168/can-i-run-animation-with-css-button

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the code below I also recommend you to review this link. https://www.w3schools.com/css/css3_animations.asp

@keyframes example {
  0%   {background-color: red;}
  25%  {background-color: yellow;}
  50%  {background-color: blue;}
  100% {background-color: green;}
}

#dark:focus{
  /*
  OR
  #dark:active{
  */
  background-color: red;
  animation-name: example;
  animation-duration: 4s;
}
<button id="dark">TEST</button>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...