2

ページがロードされたときに円が表示されるようにしようとしていますが、これは問題ありませんが、左上からではなく中央から小さいものから大きいものへと大きくする必要があります。

私が現在持っているものを見ることができます: http://thomasbritton.co.uk/projects/ebrd/

理想的には、これを CSS で実行する必要がありますが、より簡単で安定している場合は JS を使用できます。

何か案は?

アニメーション部分のCSSも次のとおりです。

.circle a {
  border-radius: 150px;
  color: #fff;
  height: 0;
  position: absolute;
  text-decoration: none;
  width: 0;
}

.circle a.grow {
  -webkit-animation-name: grow;
  -webkit-animation-duration: 2.2s;
  -webkit-animation-timing-function: ease;
  -webkit-animation-iteration-count: 1;
  -webkit-animation-direction: normal;
  -webkit-animation-delay: 0;
  -webkit-animation-play-state: running;
  -webkit-animation-fill-mode: forwards;

  -moz-animation-name: grow;
  -moz-animation-duration: 2.2s;
  -moz-animation-timing-function: ease;
  -moz-animation-iteration-count: 1;    
  -moz-animation-direction: normal;
  -moz-animation-delay: 0;
  -moz-animation-play-state: running;
  -moz-animation-fill-mode: forwards;

  animation-name: grow;
  animation-duration: 2.2s;
  animation-timing-function: ease;
  animation-iteration-count: 1; 
  animation-direction: normal;
  animation-delay: 0;
  animation-play-state: running;
  animation-fill-mode: forwards;
}

@-webkit-keyframes grow {
  0% { -moz-transform: scale(0); }
  100% { -moz-transform: scale(1); }
}

@-moz-keyframes grow {
  0% { -moz-transform: scale(0); }
  100% { -moz-transform: scale(1); height: 168px; width: 168px; }
}

@keyframes grow {
  0% { -moz-transform: scale(0); }
  100% { -moz-transform: scale(1); }
}
4

5 に答える 5

5

必要なことの大まかな例を次に示します: jsfiddle.net/UxtJV/。JS を少し使用して、円をアニメーション化するクラスを追加します。それはwidth、、、およびプロパティがアニメーション化され、与えられheightます。topleftposition: relative

div.circle {
    position: relative;

    width: 0px;
    height: 0px;
    top: 50px;
    left: 50px;

    -webkit-transition-duration: 2s;
    -webkit-transition-property: all;
    -webkit-transition-timing-function: ease-in-out;

    text-align: center;
    background: red;
    color: white;
    border-radius: 100%;
    padding: 20px;
    overflow: hidden;
}

div.circle.open {
    top: 0px;
    left: 0px;
    width: 100px;
    height: 100px;
}​
于 2012-02-16T23:43:45.007 に答える
2

そのためには、アニメーションに次のものを含める必要があります。

  1. 幅と高さを増やします。
  2. 上と左を増やします。

ちょっとした作業ですが、あなたが求めたことを正確に実行します。

于 2012-02-16T23:28:03.850 に答える
2

ケースに Jquery や Javascript を使用する必要はありません。純粋な CSS で実現できます。

アニメーション div で position プロパティを使用しないでください。これにより、アニメーションが遅くなります。代わりに、パフォーマンスの高いアニメーションには変換を使用してください。

<div class="circle__wrapper">
  <a class="circle" href="#"></a>
</div>

/* circle__wrapper will help you to position the div in the center of the page */
.circle__wrapper { 
  position: fixed; 
  top: 50%; 
  left: 50%; 
  -webkit-transform: translate(-50%, -50%); 
  transform: translate(-50%, -50%); 
}

.circle__wrapper a.circle { 
  display:block; 
  height: 168px; 
  width: 168px; 
  background-color: #fea733; 
  -webkit-border-radius: 50%; 
  -moz-border-radius: 50%; 
  border-radius: 50%; 
  -webkit-animation: growUp 2s 1.5s; /* You can remove 1.5s if you don't want delay */
  -moz-animation: growUp 2s 1.5s; 
  -ms-animation: growUp 2s 1.5s; 
  -o-animation: growUp 2s 1.5s; 
  animation: growUp 2s 1.5s; 
}


@-webkit-keyframes growUp {   
  0%  { -webkit-transform: scale(0); }
  100% { -webkit-transform: scale(1); }
}

@-moz-keyframes growUp {
  0%  { -moz-transform: scale(0); }
  100% { -moz-transform: scale(1); }
}

@-o-keyframes growUp {
  0%  { -o-transform: scale(0); }
  100% { -o-transform: scale(1); }
}

@-ms-keyframes growUp {
  0%  { -ms-transform: scale(0); }
  100% { -ms-transform: scale(1); }
}

@keyframes growUp {
  0%  { transform: scale(0); }
  100% { transform: scale(1); }
}

お役に立てれば。

于 2014-11-18T10:26:50.910 に答える
1

誰かが機能するjQueryソリューションを探している場合に備えて、ここにあります...

HTML

<div class=circle1></div>

CSS

.circle1 {
    position:absolute; top:50px; left:50px;
    width: 0px; height: 0px;
    border:1px solid red;
    padding:20px;
    border-radius:50%;
}

JS

$(".circle1").mouseover(function() {
      $(this).animate({top:"0", left:"0", width:"100px", height:"100px", opacity: 0}, 200);  
}).mouseout(function() {
      $(this).animate({top:"50px", left:"50px", width:"0", height:"0", opacity: 1}, 200);
});

そして、ここにデモがあります - http://jsbin.com/esiLULEb/1/

于 2013-11-14T12:25:55.347 に答える
1

アニメーションと翻訳プロパティを組み合わせてみてください。

これは別のオプションかもしれません:

transform-origin: top right; /* 50% 50% or whatever*/

ここに投稿されているように...

于 2012-02-16T23:34:39.207 に答える