同一页面多个带有tab标签栏目的问题。同一个页面多个tab标签问题。满意加分!
这里是tab标签实例,但是实际情况同一个页面里有多个同样的栏目。直接复制div后id冲突、页面显示不正常。谁能帮我改这段代码?<!DOCTYPEHTMLPUBLIC"-/...
这里是tab标签实例,但是实际情况同一个页面里有多个同样的栏目。直接复制div后id冲突、页面显示不正常。谁能帮我改这段代码?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<title>自适应宽度的标签导航</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
.con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH:50%; background:url(images/kktopbg01.jpg) top left no-repeat;
}
#tags {
margin:0;
margin-left:14px;
height:31px;
padding:0;
background:url(images/kktopbg02.jpg) bottom right no-repeat;
}
#tags LI {
FLOAT: left;
MARGIN-RIGHT: 1px;
HEIGHT: 31px;
background:none;
LIST-STYLE-TYPE:none;
}
#tags LI A {
FLOAT: left;
HEIGHT: 23px;
padding:0px 20px 0px 20px;
COLOR: #666;
LINE-HEIGHT: 31px;
TEXT-DECORATION: none;
background:none;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 31px; BACKGROUND: url(images/tagleft.jpg) no-repeat left bottom;
}
#tags LI.selectTag A {
COLOR: #fff; LINE-HEIGHT: 31px; HEIGHT: 31px; font-weight:bold; BACKGROUND: url(images/tagright.jpg) no-repeat right bottom;
}
#tagContent {
background:url(images/kkbgleft.jpg) top left no-repeat;
}
.tagContent {
DISPLAY: none;
margin:0;
height:250px;
padding:10px;
COLOR: #474747;
background:url(images/kkbgright.jpg) right top no-repeat;
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
</HEAD>
<BODY>
<DIV class="con">
<UL id=tags>
<LI><A onClick="selectTag('tagContent0',this)" href="javascript:void(0)">标签一</A> </LI>
<LI class=selectTag><A onClick="selectTag('tagContent1',this)" href="javascript:void(0)">标签二</A> </LI>
<LI><A onClick="selectTag('tagContent2',this)" href="javascript:void(0)">标签三标签三标签三标签三标签三</A> </LI>
</UL>
<DIV id=tagContent>
<DIV class=tagContent id=tagContent0>第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id=tagContent1>第二个标签的内容</DIV>
<DIV class=tagContent id=tagContent2>第三个标签的内容</DIV>
</DIV>
</DIV>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
</BODY></HTML> 展开
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD>
<title>自适应宽度的标签导航</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>BODY {
FONT-SIZE: 14px; FONT-FAMILY: "宋体"
}
OL LI {
MARGIN: 8px
}
.con {
FONT-SIZE: 12px; MARGIN: 0px auto; WIDTH:50%; background:url(images/kktopbg01.jpg) top left no-repeat;
}
#tags {
margin:0;
margin-left:14px;
height:31px;
padding:0;
background:url(images/kktopbg02.jpg) bottom right no-repeat;
}
#tags LI {
FLOAT: left;
MARGIN-RIGHT: 1px;
HEIGHT: 31px;
background:none;
LIST-STYLE-TYPE:none;
}
#tags LI A {
FLOAT: left;
HEIGHT: 23px;
padding:0px 20px 0px 20px;
COLOR: #666;
LINE-HEIGHT: 31px;
TEXT-DECORATION: none;
background:none;
}
#tags LI.emptyTag {
BACKGROUND: none transparent scroll repeat 0% 0%; WIDTH: 4px
}
#tags LI.selectTag {
MARGIN-BOTTOM: -2px; POSITION: relative; HEIGHT: 31px; BACKGROUND: url(images/tagleft.jpg) no-repeat left bottom;
}
#tags LI.selectTag A {
COLOR: #fff; LINE-HEIGHT: 31px; HEIGHT: 31px; font-weight:bold; BACKGROUND: url(images/tagright.jpg) no-repeat right bottom;
}
#tagContent {
background:url(images/kkbgleft.jpg) top left no-repeat;
}
.tagContent {
DISPLAY: none;
margin:0;
height:250px;
padding:10px;
COLOR: #474747;
background:url(images/kkbgright.jpg) right top no-repeat;
}
#tagContent DIV.selectTag {
DISPLAY: block
}
</STYLE>
</HEAD>
<BODY>
<DIV class="con">
<UL id=tags>
<LI><A onClick="selectTag('tagContent0',this)" href="javascript:void(0)">标签一</A> </LI>
<LI class=selectTag><A onClick="selectTag('tagContent1',this)" href="javascript:void(0)">标签二</A> </LI>
<LI><A onClick="selectTag('tagContent2',this)" href="javascript:void(0)">标签三标签三标签三标签三标签三</A> </LI>
</UL>
<DIV id=tagContent>
<DIV class=tagContent id=tagContent0>第一个标签的内容</DIV>
<DIV class="tagContent selectTag" id=tagContent1>第二个标签的内容</DIV>
<DIV class=tagContent id=tagContent2>第三个标签的内容</DIV>
</DIV>
</DIV>
<SCRIPT type=text/javascript>
function selectTag(showContent,selfObj){
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var taglength = tag.length;
for(i=0; i<taglength; i++){
tag[i].className = "";
}
selfObj.parentNode.className = "selectTag";
// 操作内容
for(i=0; j=document.getElementById("tagContent"+i); i++){
j.style.display = "none";
}
document.getElementById(showContent).style.display = "block";
}
</SCRIPT>
</BODY></HTML> 展开
6个回答
展开全部
可以动态添加,看需要然后添加多少个tab标签,给id值赋动态的.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
div.a a:nth-child(3)
{
****: ****;
}
{
****: ****;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
div.a a:nth-child(3)
{
****: ****;
}
{
****: ****;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-09-23
展开全部
div.a a:nth-child(3)
{
****: ****;
}
{
****: ****;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-09-22
展开全部
div.a a:nth-child(3)
{
****: ****;
}
{
****: ****;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询