如何隐藏DIV,它们短暂显示在页面上加载 [英] How to Hide DIVs, they are Showing for a Split Second on page Load
问题描述
我做了一个非常快速的jQuery幻灯片,我正在用它来隐藏DIV,这些DIV直到轮到他们时才显示:
I have made a very quick jQuery slideshow, and I'm using this to hide the DIVs which shouldn't be shown until it's their turn:
$(document).ready(function() {
//Hide All Div's Apart From First
$('div#gall2').hide();
$('div#gall3').hide();
$('div#gall4').hide();
但是在加载页面时,您可以在隐藏之前立即看到DIV的gall2 gall3和gall4.
But on loading the page you can see DIV's gall2 gall3 and gall4 for a split second before they are hidden.
可以在我的CSS内添加内容吗?
Would it be OK to just add inside my CSS:
#gall2, #gall3, #gall4{ display:none;}
这将解决他们只显示一秒钟的问题,只是想知道它是否可以接受
This would solve the problem of them showing for a split second, just want to know if it's acceptable
推荐答案
禁用CSS很好,但是没有JS的用户将永远看不到它们.
Disabling in CSS is fine, but then users without JS will never see them.
要仅对使用JS的用户禁用,请标记正文和相应的CSS:
To disable for users with JS only, mark the body and appropriate CSS:
<body>
<script type="text/javascript">
document.body.className += " js";
</script>
CSS:
.js #gall2, .js #gall3, .js #gall4 { display: none; }
这篇关于如何隐藏DIV,它们短暂显示在页面上加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!