2016-06-28 20 views
2

Ich möchte die Schaltfläche von rechts unten bis rechts oben schweben. Während es schwebt, kommt es zur Mitte links, wie im angehängten Bild gezeigt. Ich habe ein paar Schritte versucht, aber es funktioniert nicht richtig. Jede Hilfe wird sehr geschätzt. Vielen Dank!Floating-Taste mit css3 Animation

.animated { 
 
    -webkit-animation-duration: 1s; 
 
    animation-duration: 1s; 
 
    -webkit-animation-fill-mode: both; 
 
    animation-fill-mode: both; 
 
} 
 

 
.animated.infinite { 
 
    -webkit-animation-iteration-count: infinite; 
 
    animation-iteration-count: infinite; 
 
} 
 

 
.bounceInUp { 
 
    -webkit-animation-name: bounceInUp; 
 
    animation-name: bounceInUp; 
 
} 
 

 
@keyframes bounceInUp { 
 
    from, 60%, 75%, 90%, to { 
 
    -webkit-animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); 
 
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); 
 
    } 
 

 
    from { 
 
    opacity: 0; 
 
    -webkit-transform: translate3d(0, 3000px, 0); 
 
    transform: translate3d(0, 3000px, 0); 
 
    } 
 

 
    60% { 
 
    opacity: 1; 
 
    -webkit-transform: translate3d(0, -20px, 0); 
 
    transform: translate3d(0, -20px, 0); 
 
    } 
 

 
    75% { 
 
    -webkit-transform: translate3d(0, 10px, -1000); 
 
    transform: translate3d(0, 10px, -1000); 
 
    } 
 

 
    90% { 
 
    -webkit-transform: translate3d(0, -5px, 0); 
 
    transform: translate3d(0, -5px, 0); 
 
    } 
 

 
    to { 
 
    -webkit-transform: translate3d(0, 0, 0); 
 
    transform: translate3d(0, 0, 0); 
 
    } 
 
}
<div style="float:right;" class="animated infinite bounceInUp">Button</div>

enter image description here

+0

scheint gut funktioniert zu werden! – Pugazh

+0

@Pugazh Ich mag Float-Taste wie im Bild gezeigt, wenn es 75% sollte es Mitte kommen. – techies

Antwort

1

Statt float: right habe ich position: absolute und right: für den gewünschten Effekt verwendet. Überprüfen Sie das folgende Snippet.

Ich habe die Rahmen minimiert, bitte ändern Sie nach Ihren Bedürfnissen.

.animated { 
 
    background-color: coral; 
 
    padding: 4px 10px; 
 
    position: absolute; 
 
    right: 0px; 
 
    -webkit-animation-duration: 5s; 
 
    animation-duration: 5s; 
 
    -webkit-animation-fill-mode: both; 
 
    animation-fill-mode: both; 
 
} 
 
.animated.infinite { 
 
    -webkit-animation-iteration-count: infinite; 
 
    animation-iteration-count: infinite; 
 
} 
 
.bounceInUp { 
 
    -webkit-animation-name: bounceInUp; 
 
    animation-name: bounceInUp; 
 
} 
 
@keyframes bounceInUp { 
 
    from { 
 
    right: 0px; 
 
    opacity: 0; 
 
    -webkit-transform: translateY(100vh); 
 
    transform: translateY(100vh); 
 
    } 
 
    60% { 
 
    opacity: 1; 
 
    right: 40%; 
 
    } 
 
    to { 
 
    right: 0px; 
 
    -webkit-transform: translateY(0px); 
 
    transform: translateY(0px); 
 
    } 
 
}
<div class="animated infinite bounceInUp">Button</div>

+0

aber hier gibt es zwei gerade Übersetzung, kein Bogen – Alexis

+0

Fügen Sie alle Rahmen in Ihrer Frage hinzu und schließen Sie 'cubic-bezier()' ein – Pugazh