2016-07-12 6 views
0

thatのようにアニメーションを作成したいと思います。しかし、それは必要なように見えません。ここに私のcodeのフィドルがあります。助けてください。cicrle animation with css

.effect-1 { 
    position: relative; 
    height: 100px; 
    width: 100px; 
    margin: 100px; 
    border-radius: 50%; 
    display: block; 
    text-align: center; 
    line-height: 100px; 
    background-color: black; 
} 

.effect-1::after { 
    position: absolute; 
    top: -10px; 
    left: -10px; 
    height: 100%; 
    width: 100%; 
    padding: 10px; 
    border-radius: 50%; 
    box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.8); 
    transform: scale(0.7, 0.7); 
    transition: all 0.2s; 
} 

答えて

1

は私の代わりにピクセル単位で高さ/幅を変更するので、スケールがホバーでtransformプロパティを変更することをお勧めしていますまた

.effect { 
 
    position: relative; 
 
    height: 100px; 
 
    width: 100px; 
 
    line-height: 100px; 
 
    border-radius: 50%; 
 
    display: block; 
 
    text-align: center; 
 
    background-color: black; 
 
    color: white; 
 
    font-size: 2em; 
 
    text-decoration: none; 
 
    margin: 1em; 
 
} 
 

 
.effect::before { 
 
    content: ''; 
 
    position: absolute; 
 
    top:0; bottom: 0; left: 0; right: 0; 
 
    margin: auto; 
 
    height: 100%; width: 100%; 
 
    border:5px solid black; 
 
    border-radius: inherit; 
 
    box-sizing: border-box; 
 
    transform: scale(0.5); 
 
    transition: .3s; 
 
} 
 

 
.effect:hover::before { 
 
    transform: scale(1.2); 
 
}
<a href="#" class="btn effect">M</a>

、遷移プロパティする必要があります正しくオブジェクトのカスタムレイヤを作成し、最適な結果のためにホバー状態の代わりに静的状態に追加することができます。

1

フム - あなたはsample pageからCSSコードをコピーしなかった理由わかりません。それは即座に動作します(つまり、レイアウトの流れに影響するため)変換のに対しhttps://jsfiddle.net/063djx57/1/

一つ重要なことは、.effect-1:after {position: absolute;}