html制作选项卡
2015-08-23 23:26
429 查看
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Table选项卡</title>
<style type="text/css">
<!--
设置id是tabNav的ul的样式 -->ul#tabNav {
width: 400px;
list-style: none;
border-bottom: solid 1px green;
margin: 0;
padding-left: 0;
padding-bottom: 0;
*padding-bottom: 0;
}
<!--
设置id是tabNav的Ul下辖li的样式 -->ul#tabNav li {
float: left;
height: 25px;
margin: 0 10px -2px 0; <!--
关键地方 --> backgroud-color: Green;
color: black;
border: solid 1px Green;
border-bottom: 0;
padding: 0;
}
ul # tabNav a:link, ul#tabNav a:visited {
display: block;
text-decoration: none;
padding: 5px 10px 3px 10px;
}
#tabContent {
width: 400px;
height: 200px;
border: solid 1px green;
border-top-width: 0;
}
<!--
选中后的样式-->#tabNav li.tabSelected {
background-color: #FFCC00;
color: #FFFFFF;
}
</style>
<script type="text/javascript">
function showContent(index){
<!-- 根据事件获取相应的层-->
var e=document.getElementById("content"+index);
e.style.display="";
for(var i=1;i<4;i++){
<!-- 判断层编号,并隐藏其它的层-->
if(i!=index){
var e2=document.getElementById("content"+i);
e2.style.display="none";
document.getElementById("tab"+i).className="";
}
<!-- 改变选中层的类名,从而改变样式-->
else{
document.getElementById("tab"+i).className="tabSelected";
}
}
}
</script>
</head>
<body>
<ul id="tabNav">
<li onmousedown="showContent(1)" id='tab1' class="tabSelected"><a
href='#' _fcksavedurl='#'>新聞</a></li>
<li onmousedown="showContent(2)" id='tab2' class=""><a href='#'
_fcksavedurl='#'>体育</a></li>
<li onmousedown="showContent(3)" id='tab3' class=""><a href='#'
_fcksavedurl='#'>娱乐</a></li>
</ul>
<div id="tabContent">
<div id="content1">新闻内容</div>
<div id="content2">体育内容</div>
<div id="content3">娱乐内容</div>
</div>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>Table选项卡</title>
<style type="text/css">
<!--
设置id是tabNav的ul的样式 -->ul#tabNav {
width: 400px;
list-style: none;
border-bottom: solid 1px green;
margin: 0;
padding-left: 0;
padding-bottom: 0;
*padding-bottom: 0;
}
<!--
设置id是tabNav的Ul下辖li的样式 -->ul#tabNav li {
float: left;
height: 25px;
margin: 0 10px -2px 0; <!--
关键地方 --> backgroud-color: Green;
color: black;
border: solid 1px Green;
border-bottom: 0;
padding: 0;
}
ul # tabNav a:link, ul#tabNav a:visited {
display: block;
text-decoration: none;
padding: 5px 10px 3px 10px;
}
#tabContent {
width: 400px;
height: 200px;
border: solid 1px green;
border-top-width: 0;
}
<!--
选中后的样式-->#tabNav li.tabSelected {
background-color: #FFCC00;
color: #FFFFFF;
}
</style>
<script type="text/javascript">
function showContent(index){
<!-- 根据事件获取相应的层-->
var e=document.getElementById("content"+index);
e.style.display="";
for(var i=1;i<4;i++){
<!-- 判断层编号,并隐藏其它的层-->
if(i!=index){
var e2=document.getElementById("content"+i);
e2.style.display="none";
document.getElementById("tab"+i).className="";
}
<!-- 改变选中层的类名,从而改变样式-->
else{
document.getElementById("tab"+i).className="tabSelected";
}
}
}
</script>
</head>
<body>
<ul id="tabNav">
<li onmousedown="showContent(1)" id='tab1' class="tabSelected"><a
href='#' _fcksavedurl='#'>新聞</a></li>
<li onmousedown="showContent(2)" id='tab2' class=""><a href='#'
_fcksavedurl='#'>体育</a></li>
<li onmousedown="showContent(3)" id='tab3' class=""><a href='#'
_fcksavedurl='#'>娱乐</a></li>
</ul>
<div id="tabContent">
<div id="content1">新闻内容</div>
<div id="content2">体育内容</div>
<div id="content3">娱乐内容</div>
</div>
</body>
</html>
相关文章推荐
- 【HTML】仿淘宝五星评价显示任何分数
- 关于html中li的问题
- html事例
- html中将某个控件限制在框内的方法
- html使用笔记
- 最近的两个问题<input>与<frame src="/example/html/frame_a.html" name="showframe">
- html标记
- HTML标签,闭合还是不闭合?
- HTML-Ajax文件上传
- HTML中块级元素和行内元素
- html生成pdf
- HTML
- 使用HTML Purifier解决XSS问题
- html页面上轮播图片举例
- (HTML部分)特供.Net基础全套视频教程2014版(第十八天)(更新于2015年10月24日02:23:36)
- 对输入字符进行HTML转义 OR 去HTML标签
- html只允许输入的数据校验,只允许输入字母汉字数字等
- XHTML的使用规范
- html 标签
- html基础知识