我使用Jquery for Tabs,一切正常,只是在网站上刷新所有标签的内容会显示一秒钟,然后一切都恢复正常。 https://gyazo.com/3df254e9161955c2d3d1cc116f660abf
究竟是什么问题?我无法识别它。
这是我的代码:
<html>
<head>
<link rel="stylesheet" type="text/css" href="../mechanics/segments_container.css"/>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$("#tabs").tabs({
activate: function(event, ui) {
window.location.hash = ui.newPanel.attr('id');
}
});
});
</script>
</head>
<body>
<div id="tabs">
<div class ="forum_switch_buttons_wrap">
<ul style = "display:inline;">
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#General">General</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Gaming">Gaming</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Computing">Computing</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Graphics">Graphics</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Coding">Coding</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Market">Market</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Groups">Groups</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Premium">Premium</a></li>
<li style = "list-style-type: none;"><a class = "forum_switch_buttons" href="#Archive">Archive</a></li>
</ul>
</div>
<div class = "forum_wrap">
<div class = "forum_change_height_left">
<div class = "forum_container_left" style = "display:block;" >
<div class = "titlebar">
Forum
</div>
<div class = "forum_inner_container">
<div id="General">
General Content
</div>
<div id="Gaming">
Gaming Content
</div>
<div id="Computing">
Computing Content
</div>
<div id="Graphics">
Graphic Content
</div>
<div id="Coding">
Coding Content
</div>
<div id="Market">
Market Content
</div>
<div id="Groups">
Group Content
</div>
<div id="Premium">
Premium Content
</div>
<div id="Archive">
Archive Content
</div>
</div>
</div>
</div>
<div class = "forum_change_height_right">
<div class = "forum_container_right">
<div class = "titlebar">
Latest Posts
</div>
<div class = "forum_inner_container">
testtest
</div>
</div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:1)
应用css隐藏内容。
正在发生的事情是,在整个dom为ready
之前,脚本不会触发,因此您将获得“无格式内容的闪存”#34;
一个简单的css修复:
.forum_inner_container > div{
display:none
}
.forum_inner_container > div:first-child{
display:block
}
如果您在其他没有标签的网页上使用相同的课程forum_inner_container
,请将每个标签内容元素设为一个公共类,并相应调整上述规则