Edit in JSFiddle

requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||
                        window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;

var ctx = document.getCSSCanvasContext("2d", "elementy", 210, 110);

function anim() {
   this.ctx = ctx;
   this.w = 100;
   this.diff = -1;

   this.step = function() {
      if (this.w < 100 || this.w > 200) {
         this.diff = -this.diff;
      }

      this.w += this.diff;
      this.ctx.clearRect(10,10,200,100);
      this.ctx.fillStyle = 'yellow';
      this.ctx.fillRect(10,10,this.w, 100);

   }
}

(function() {   
   var obj = new anim();
   var step = function(){
      obj.step();
      requestAnimationFrame(step);
   };
   step();
})();
<div id="element"></div>
#element {
   width: 420px;
   height: 420px;
   background: -webkit-canvas(elementy);
}