渐进增强和初始显示状态 [英] Progressive Enhancement and Initial Display State
问题描述
我有一个具体的例子,但我也在寻找一般的答案.如果启用了JavaScript,我最初希望隐藏页面元素.
I have a specific example, but I'm looking for the answer in general as well. I have page elements that I want to have initially hidden if JavaScript is enabled.
示例:
- 切换表单的一部分
- 用于选择框跳转表单"的提交按钮
当页面加载后元素被隐藏时,我试图避免内容闪烁".
I am trying to avoid the 'content flash' when the elements are hidden after page load.
解决方案
为了后代的缘故,我将完整的解决方案放在这里.
I am putting the full solution here for posterity's sake.
在<head>
部分中调用的JavaScript文件:document.documentElement.className = 'js';
JavaScript file called in <head>
section: document.documentElement.className = 'js';
允许最初隐藏或显示元素的样式:
Styles that allow for initially hidden or shown elements:
.js .inithide {
display: none;
}
.initshow {
display: none;
}
.js .initshow {
display: block;
}
推荐答案
签出此解决方案.过去对我有用:
Check this solution out. It has worked for me in the past:
http://www.learningjquery.com/2008/10/1-避免未格式化内容的闪光方式
这篇关于渐进增强和初始显示状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!