html - CSS3 or Javascript - Simple Fill Animation -
i'm trying create simple animation when user hovers on element, element contained within fills parent. currently, have jsfiddle that.
but, want finish few other features i'm not sure can in css3.
i'm trying find way to, upon having inner circle fill parent, (ie when width/height = 300px), i'd fill pause , not disappear after animation complete.
when user moves mouse outside :hover range, animation reverse direction opposed abruptly stopping.
i've gotten far css3 not sure can implement these 2 features without resorting javascript. know of way of doing entirely in css3/does know if possible these last 2 features in css3, because can't seem find anything.
.circle { width: 300px; height: 300px; background-color: white; border: 1px solid #000000; overflow: hidden; border-radius: 150px; -moz-border-radius: 150px; -webkit-border-radius: 150px; } .filler { width: 0px; height: 0px; background-color: red; border: none; position: relative; left: 50%; top: 50%; border-radius: 150px; -mox-border-radius: 150px; -webkit-border-radius: 150px; animation: empty 1s; } .circle:hover .filler { animation: fill 2s; -moz-animation: fill 2s; -webkit-animation: fill 2s; background-color: blue; } @keyframes fill { {background: red; height: 0px; width: 0px;} {background: green; height: 300px; width: 300px; top: 0%; left: 0%;} } @-moz-keyframes fill /* firefox */ { {background: red; height: 0px; width: 0px;} {background: green; height: 300px; width: 300px; top: 0%; left: 0%;} } @-webkit-keyframes fill /* safari , chrome */ { {background: red; height:0px; width:0px;} {background: green; height: 300px; width: 300px; top: 0%; left: 0%;} } @keyframes empty { {background: red; height: 0px; width: 0px; top: 50%; left: 50%;} } @-moz-keyframes empty { {background: red; height: 0px; width: 0px; top: 50%; left: 50%;} } @-webkit-keyframes empty { {background: red; height: 0px; width: 0px; top: 50%; left: 50%;} }
you don't need keyframes simple animation. here css need:
.circle { position: relative; width: 300px; height: 300px; background-color: white; border: 1px solid #000000; border-radius: 150px; overflow: hidden; } .filter { position: absolute; top: 50%; left: 50%; width: 0; height: 0; background-color: red; border-radius: 0px; -webkit-transition: 1s; -moz-transition: 1s; -o-transition: 1s; transition: 1s; } .circle:hover .filter { top: 0; left: 0; width: 100%; height: 100%; border-radius: 150px; background-color: blue; }
and html:
<div class="circle"> <div class="filter"></div> </div>
here example: http://jsbin.com/agekef/1/edit
Comments
Post a Comment