简体   繁体   English

如何在文档准备好之前强制从 js 准备好边距

[英]How to force margins to be ready from js before document ready

I am using an effect a website I have built to detect and move the website from on document ready as well as when the browser window is resized.我正在使用我构建的网站效果来检测和移动网站,使其从文档就绪以及浏览器 window 调整大小时开始。 There is an effect I must address that I did not consider.我必须解决一个我没有考虑过的影响。 When the page loads it reads css from the css file and once document is ready it reads from dynamic value provided from js.当页面加载时,它会从 css 文件中读取 css ,一旦文档准备好,它就会从 js 提供的动态值中读取。 I was hoping someone can give some insight on how I can read the js value before the css value.我希望有人能对我如何在 css 值之前读取 js 值提供一些见解。

Thank you in advance,先感谢您,

DT DT

I made this example http://jsfiddle.net/efortis/kUfdE/我做了这个例子http://jsfiddle.net/efortis/kUfdE/

First, hide it by default in the CSS with display:none首先,在 CSS 中默认隐藏它display:none

.orangeBox{
  background: orange;
  display: none;
}

Then display it with javascript, equivalent to .css('display', 'block') to show the display:none element然后用 javascript 显示,相当于.css('display', 'block')显示display:none元素

$(document).ready(function () {
  $('.orangeBox').delay(1500).fadeIn('slow');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM