在CSS之前加载DOM? [英] Load DOM before css?

查看:96
本文介绍了在CSS之前加载DOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的jQuery代码在页面加载后立即将元素的高度设置为0px,然后将其动画设置为500px.

My jQuery code sets the height of an element to 0px as soon as the page loads, then animates it to 500px.

在我的CSS中,此元素已设置为500px(以防有人关闭了javascript).

In my CSS, this element is already set to 500px (in case anyone has javascript turned off).

我尝试在链接到样式表的标签上使用"DEFER",以便最终加载CSS,但这会导致在浏览页面之间出现空白的白页,这是我不想要的,因为我失去了想要的平滑页面过渡效果.

I tried 'DEFER' on the tag where I link to the stylesheet so that the CSS loads in last of all, but that causes a blank white page to show up between navigating through pages - which I don't want, because I lose the smooth page transition effects that I am after.

有没有一种方法可以将CSS中的高度设置为0px,并且如果javascript JavaScript已关闭,是否可以将其设置为500px? :\实际上,这就是我所追求的.

Is there a way that I can set the height in the CSS to 0px and IF javascript IS turned off, have it set to 500px, perhaps? :\ That's what I'm after, in effect.

有什么想法吗?

非常感谢您的帮助.

推荐答案

如果您为此感到惊讶,我将提供一个noscript.css文件.在您的:做这样的事情:

If you're married to that effect, I would include a noscript.css file. Do something like this in your :

<noscript>
    <link rel="stylesheet" type="text/css" href="noscript.css" />
</noscript>

在没有javascript的情况下,在其中包含要加载的所有CSS.

Include any CSS there that you want to be loaded in the absence of javascript.

这篇关于在CSS之前加载DOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆