[英]Make an element “Land” in position when page loads
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. 加载页面时,我想使徽标淡入并同时从下向上移动20-30像素。 I have this code to make it fade in, and is working perfect:
我有以下代码可以使其淡入,并且运行良好:
$(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.
我读了很多有关使JavaScript向元素添加新类或ID的知识,以使该类具有不同的padding top或margin top,但我无法使其正常工作。
Thanks in advance. 提前致谢。
Try adding 尝试添加
("#logo").css("padding-top", "15px");
to your "document ready" function. 您的“文档准备就绪”功能。
Source: http://www.w3schools.com/jquery/jquery_css.asp 资料来源: http : //www.w3schools.com/jquery/jquery_css.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.