Jump to content
Carlos Rocha

Inserir keyframe via jQuery?

Recommended Posts

Carlos Rocha

Como inserir esse keyframe via jQuery?

Tentei da forma abaixo mas não funcionou:

	  var tempoTransicao = 5;
	  var quantasImagens = $("ul.slider li img").size();
	  var tamanhoIntervalos = Math.round(100/quantasImagens);
      var t = 0;

     $('<style> @keyframe animacao', function() {

        for (i = 1; i <= quantasImagens; i++) {                              

        tMin = t + tempoTransicao;
        tMax = t + tamanhoIntervalos;    
        t+=tamanhoIntervalos;

        document.write(
                 tMin+"%" {margin-left: 0} 
                 tMax+"%" {margin-left: 0} 
        );

        if(i==0) tMin=0;
        if(i==quantasImagens) tMax=100;        
    }
    }).appendTo('document');

HTML

  <ul class="slider">
    <li> 
      <img src="_imgs/_slideShow/1.png" /> 
      <img src="_imgs/_slideShow/2.png" /> 
      <img src="_imgs/_slideShow/3.png" /> 
      <img src="_imgs/_slideShow/4.png" /> 
     </li>
  </ul>


 

Edited by carcleo

Share this post


Link to post
Share on other sites
N3lson

Acho k o teu problema reside no facto de estares a inserir <li> <img><img> e deverias colocar <li><img></li> <li><img></li>


You can't do it, kid. But don't worry, my boy. You're not the only one. No one else can do it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.