smooth transition between pages when redirecting with jquery

前端 未结 3 1201
攒了一身酷
攒了一身酷 2021-01-25 21:46

I am trying to get a smooth transition when I redirect users. First by fading out the page then redirecting and and fadeIn.

Here is my redirect

if ( dat         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-25 22:18

    Don't use pure css to hide the content originally. If you do, users with JavaScript turned off will not see your content. Instead, only hide when javascript is available.

    .js-enabled div.container_16,
    .js-enabled .grid_16 {
      display: none;
    }
    

    Include this line of javascript at the very top of the body:

    $(document.body).addClass('js-enabled');
    

    Then in your animation function, after you've hidden .grid_16, include this line to return things to normal:

    $(document.body).removeClass('js-enabled');
    

    If you want, you can be more specific and target the hiding styles to the particular elements you want to hide. But I don't know if that's practical for your case -- too few details.

提交回复
热议问题