在页面加载时使元素“Land”处于适当位置

时间:2022-08-24 17:40:46

When my page loads I want to make my logo fade in and move like 20-30px from down to up at the same time. I have this code to make it fade in, and is working perfect:

当我的页面加载时,我想让我的徽标淡入并同时从20-30px向下移动。我有这个代码使它淡入,并且工作完美:

$(document).ready(function() {
  $('#logo').fadeIn(2000);
});
    #logo {
      width: 80%;
      max-width: 650px;
      padding-top: 50px;
      position: absolute;
      left: 50%;
      top: 50%;
      -webkit-transform: translate(-50%, -50%);
      transform: translate(-50%, -50%);
    }
<img id="logo" src="assets/img/mainlogo.png" style="display: none" />

But I could really use some help to make it move. I read a lot about make JavaScript to add a new class or Id to the element so that class have a different padding top or margin top but I can't make it work.

但我真的可以使用一些帮助来使它移动。我读了很多关于make JavaScript来为元素添加一个新的类或Id,以便类具有不同的填充顶部或边缘顶部,但我无法使其工作。

Thanks in advance.

提前致谢。

1 个解决方案

#1


0  

Try adding

("#logo").css("padding-top", "15px"); 

to your "document ready" function.

到你的“文件就绪”功能。

Source: http://www.w3schools.com/jquery/jquery_css.asp

#1


0  

Try adding

("#logo").css("padding-top", "15px"); 

to your "document ready" function.

到你的“文件就绪”功能。

Source: http://www.w3schools.com/jquery/jquery_css.asp