How to make this feature animated?

$(function() { $(window).scroll(function() { if($(window).scrollTop() > 100) { $(".header").css({ width: "100%", position: "fixed" }) } else { $(".header").css({ width: "auto", position: "relative" }) } }); }); 

Closed due to the fact that off-topic participants Pavel Mayorov , pavel , aleksandr barakin , fori1ton , Denis Aug 31 '16 at 7:50 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Pavel Mayorov, pavel, fori1ton, Denis
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 12
  • one
    @VladD broke! The best answer)) - korytoff
  • What do you want to animate? - korytoff
  • one
    Now, if the topic was "how to underestimate a function", then the respondent would have liked the third part straight from another author: D - Qwertiy
  • one
    @VladD, cool !!! :) - Qwertiy

1 answer 1

 $(function() { $(window).scroll(function() { if($(window).scrollTop() > 100) { $(".header").animate({ width: "100%", position: "fixed" },5000); } else { $(".header").animate({ width: "auto", position: "relative" },5000); } }); }); 
  • Your code is not valid. - Dmitriy Simushev
  • Why not valid? - Onotol
  • And you just put ,5000 where you want? ;) - Dmitriy Simushev