html - Animating div color -


i have been intensely following code trying understand how animate border. tweaking code, able animate border color.

however, not able achieve effect of animating div's background color using same structure of @keyframes

could please (am not trying alternate solution, want use @keyframes)

html & css:

.wrapper {    border: 1px solid;    width: 100%;    height: 100%;    margin-right: auto;    margin-left: auto;  }  .green {    height: 200px;    width: 200px;    animation: 1s animategreen ease infinite;    margin-right: auto;    margin-left: auto;  }  @keyframes animategreen {    {      background-color: rgba(0, 255, 0, 1);    }  }
<div class="wrapper">    <div class="green">    </div>  </div>

you need combine 2 animations:

animation: animation1 1s infinite, animation2 1s infinite, example

here's code both working:

.wrapper {  border: 1px solid;  width: 100%;  height: 100%;  margin-right: auto;  margin-left: auto;    }    .green {  height: 200px;  width: 200px;    animation: animategreen 1s infinite, animateborder 1s infinite;    margin-right: auto;  margin-left: auto;  }    @keyframes animategreen {          0%     {background-color:red;}      100%  {background-color:green;}  }    .border {    border: 3px solid rgba(255,0,0,1);  }    @keyframes animateborder {  {    border-top-color: rgba(0,0,102,1);  border-right-color: rgba(0,0,102,1);  border-bottom-color: rgba(0,0,102,1);  border-left-color: rgba(0,0,102,1);  border-top-width: 3px;  border-right-width: 3px;  border-bottom-width: 3px;  border-left-width: 3px;  border-top-color: rgba(51,0,204,1);  border-right-color: rgba(51,0,204,1);  border-bottom-color: rgba(51,0,204,1);  border-left-color: rgba(51,0,204,1);        }
<div class="wrapper">  <div class="green border">  </div>  </div>

sorry css mess, made fast :)


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -