How do I animate a scale css property using jquery?

前端 未结 5 673
难免孤独
难免孤独 2020-12-20 10:47

I am trying to have a circle div with the class of \"bubble\" to pop when a button is clicked using jQuery. I want to get it to appear from nothing and grow to its full size

5条回答
  •  隐瞒了意图╮
    2020-12-20 11:40

    Currently you cannot use animate with the transform property see here

    However you can add a css transition value and modify the css itself.

    var scale = 1;
    setInterval(function(){
      scale = scale == 1 ? 2 : 1
      $('.circle').css('transform', 'scale('+scale+')')
    }, 1000)
    .circle {
      margin: 20px auto;
      background-color: blue;
      border-radius: 50%;
      width: 20px;
      height: 20px;
      transform: scale(1);
      transition: transform 250ms ease-in-out;
    }
    
    

提交回复
热议问题