html - Why is this CSS transition not working as intended? -


this question has answer here:

i have submit button in form , i'm trying make simple on-hover transition. want swap colors of button's text , button's background color. way have right now, text transitions on time, background color still switching colors instantly. how fix make background color change on time? using google chrome, put in -webkit-transition. once working i'll add others other browsers.

here's simplified code:

<form method="post" action="processregistration.php">      <input class="submitbutton" type="submit" name="submit" value="create account" />  <form> 

css:

#signupform form .submitbutton {     margin: 0 auto;     border-radius: 5px;     border: solid 2px #66cc66;     background-color: #66cc66;     color: white;     -webkit-transition: background-color 1s;     -webkit-transition: color 0.5s; } #signupform form .submitbutton:hover {       background-color: white;       color: #66cc66;       -webkit-transition: background-color 1s;       -webkit-transition: color 0.5s; } 

http://jsfiddle.net/ewkruuk3/

this because declaring transition twice. overriding first transition second one. in css if there 2 of same rules, last 1 applies. have seperate both comma in 1 declaration.

transtion: color .5s, background-color 1s; 

ideally though css can simplified following:

.submitbutton {     // other rules      background-color: #66cc66;     color: white;      -webkit-transition: background-color 1s, color 0.5s;     transition: background-color 1s, color 0.5s; // include browser compatability      &:hover {         background-color: white;         color: #66cc66;     } } 

you don't need transition on :hover transition in parent rule apply.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -