Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2010
    Messaggi
    24

    Start/Stop animation CSS da javascript

    Ciao a tutti,
    sto facendo moltissime prove ma proprio non riesco ad avviare/fermare un'animazione CSS.
    Ho un esempio che funziona ma che utilizza un link come oggetto scatenante la funzione CSS.
    Ho bisogno di farlo tramite un asp.net button
    Ecco l'esempio funzionante:
    codice HTML:
    < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>I Love CSS</title><style type="text/css">    @-webkit-keyframes MoveRight {      0% { -webkit-transform: translateX(0px); }      100% { -webkit-transform: translateX(500px); }    }        .moveRightAnimation {        -webkit-animation-name: MoveRight;        -webkit-animation-direction: normal;        -webkit-animation-timing-function: linear;        -webkit-animation-iteration-count: infinite;        -webkit-animation-duration: 5s;        position:absolute;    }</style>
    <script type="text/javascript">    function toggleAnimation(what) { // 'what' is the ID of the element that has the animation class applied to it        if(what != null && document.getElementById(what) != null) {            var elem = document.getElementById(what);            if(elem.style.webkitAnimationPlayState == 'paused')                elem.style.webkitAnimationPlayState = 'running';            else                elem.style.webkitAnimationPlayState = 'paused';        }    }</script></head>
    <body>    <div id="iLikeToMoveIt" class="moveRightAnimation">I Like to Move It Move It...</div>    <p>        <a href="javascript:toggleAnimation('iLikeToMoveIt');">Toggle Animation</a>    </p></body></html>

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    A) La formattazione del codice è un disastro
    B) Asp.net e css cosa centra javascript?
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.