JSP+css标签页
2014-03-20 12:00
183 查看
本文转自:点击打开链接
习惯了js框架ext,jquery等。突然要用jsp+css实现标签页的效果,突然不适应了,在网上so了一下发现一个不错的实现方式,现引用一下:原版请参考:http://blog.csdn.net/uniorg/article/details/3176266,
Html代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>标签示例</title>
<style type="text/css">
body { font-size:14px; font-family:"宋体"}
ol li { margin:8px}
#con { font-size:12px; width:600px; margin:0 auto}
#tags { height:23px; width:400px; margin:0; padding:0; margin-left:10px}
#tags li { float:left; margin-right:1px; background:url(images/tagleft.gif) no-repeat left bottom; height:23px; list-style-type:none}
#tags li a { text-decoration:none; float:left; background:url(images/tagright.gif) no-repeat right bottom; height:23px; padding:0px 10px; line-height:23px; color:#999}
#tags li.emptyTag { width:4px; background:none}
#tags li.selectTag { background-position: left top; position:relative; height:25px; margin-bottom:-2px}
#tags li.selectTag a { background-position: right top; color:#000; height:25px; line-height:25px;}
#tagContent { padding:1px; background-color:#fff; border:1px solid #aecbd4;}
.tagContent { background:url(images/bg.gif) repeat-x; padding:10px; color:#474747; width:576px; display:none}
#tagContent div.selectTag{ display:block}
</style>
</head>
<body>
<h1>标签示例</h1>
<ol>
<li>使用JS实现tab标签效果</li>
<li>标签宽度随文字的数量自适应</li>
<li>支持 IE、Firefox、Chrome、Safari、opera</li>
</ol>
<div id="con">
<ul id="tags">
<li><a href="javascript:void(0)" onclick="selectTag('tagContent0',this)">标签一</a></li>
<li class="selectTag"><a href="javascript:void(0)" onclick="selectTag('tagContent1',this)">标签二</a></li>
<li><a href="javascript:void(0)" onclick="selectTag('tagContent2',this)">自适应宽度的标签</a></li>
</ul>
<div id="tagContent">
<div id="tagContent0" class="tagContent">第一个标签的内容<br />第一个标签的内容<br />第一个标签的内容</div>
<div id="tagContent1" class="tagContent selectTag">第二个标签的内容<p>标签背景图1:<img src="images/tagleft.gif" align="top"><br>标签背景图2:<img src="images/tagright.gif" align="top"><br>内容渐变背景图(1象素宽):<img src="images/bg.gif" align="top"></p></div>
<div id="tagContent2" class="tagContent">第三个标签的内容<p>放大观看标签背景图:<img src="images/tagleft.gif" align="top" width="300" height="100"></p></div>
</div>
</div>
<script type="text/javascript">
function selectTag(showContent,selfObj){
selfObj.blur();
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var tagtaglength = 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>
效果如图:
大小: 20.9 KB
my_jsp_tab.zip (5.6 KB)
下载次数: 121
习惯了js框架ext,jquery等。突然要用jsp+css实现标签页的效果,突然不适应了,在网上so了一下发现一个不错的实现方式,现引用一下:原版请参考:http://blog.csdn.net/uniorg/article/details/3176266,
Html代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>标签示例</title>
<style type="text/css">
body { font-size:14px; font-family:"宋体"}
ol li { margin:8px}
#con { font-size:12px; width:600px; margin:0 auto}
#tags { height:23px; width:400px; margin:0; padding:0; margin-left:10px}
#tags li { float:left; margin-right:1px; background:url(images/tagleft.gif) no-repeat left bottom; height:23px; list-style-type:none}
#tags li a { text-decoration:none; float:left; background:url(images/tagright.gif) no-repeat right bottom; height:23px; padding:0px 10px; line-height:23px; color:#999}
#tags li.emptyTag { width:4px; background:none}
#tags li.selectTag { background-position: left top; position:relative; height:25px; margin-bottom:-2px}
#tags li.selectTag a { background-position: right top; color:#000; height:25px; line-height:25px;}
#tagContent { padding:1px; background-color:#fff; border:1px solid #aecbd4;}
.tagContent { background:url(images/bg.gif) repeat-x; padding:10px; color:#474747; width:576px; display:none}
#tagContent div.selectTag{ display:block}
</style>
</head>
<body>
<h1>标签示例</h1>
<ol>
<li>使用JS实现tab标签效果</li>
<li>标签宽度随文字的数量自适应</li>
<li>支持 IE、Firefox、Chrome、Safari、opera</li>
</ol>
<div id="con">
<ul id="tags">
<li><a href="javascript:void(0)" onclick="selectTag('tagContent0',this)">标签一</a></li>
<li class="selectTag"><a href="javascript:void(0)" onclick="selectTag('tagContent1',this)">标签二</a></li>
<li><a href="javascript:void(0)" onclick="selectTag('tagContent2',this)">自适应宽度的标签</a></li>
</ul>
<div id="tagContent">
<div id="tagContent0" class="tagContent">第一个标签的内容<br />第一个标签的内容<br />第一个标签的内容</div>
<div id="tagContent1" class="tagContent selectTag">第二个标签的内容<p>标签背景图1:<img src="images/tagleft.gif" align="top"><br>标签背景图2:<img src="images/tagright.gif" align="top"><br>内容渐变背景图(1象素宽):<img src="images/bg.gif" align="top"></p></div>
<div id="tagContent2" class="tagContent">第三个标签的内容<p>放大观看标签背景图:<img src="images/tagleft.gif" align="top" width="300" height="100"></p></div>
</div>
</div>
<script type="text/javascript">
function selectTag(showContent,selfObj){
selfObj.blur();
// 操作标签
var tag = document.getElementById("tags").getElementsByTagName("li");
var tagtaglength = 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>
效果如图:
大小: 20.9 KB
my_jsp_tab.zip (5.6 KB)
下载次数: 121
相关文章推荐
- jsp 引入java文件、标签、css
- 关于java后台转发jsp到easyUI tabs标签里 css js出现404问题
- 【jsp总结】jsp成servlet、错误页面、pageContext九大隐式、静态包含、jsp标签、EL表达式、JSTL、CSS中的路径写法
- JSP自定义标签开发(八)—— xx.tag自定义标签开发之分页标签(jquery + div +css 美化)
- css配合JavaScript实现tab标签切换效果
- JSP---演示ErroPage、isErroPage和jsp:forword标签
- 自定义JSP中的Taglib标签之四自定义标签中的Function函数
- 正则表达式运用到JSP页面(使用在input 标签内)
- Chrome64基础 开发者工具 查看a标签处于:hover时的css代码
- JSP2.0 tags自定义标签学习笔记
- jsp页面中JSTL/EL标签引用java后台静态static字段的方法总结
- jsp,css,js中变量的传递关系
- css 去除button a input标签的虚线边框
- OpenCms JSP标签详解——cms:property标签
- jsp标签
- JSP中JSTL提供的函数标签EL表达式操作字符串的方法
- jsp base标签与meta标签学习小结
- CSS_td标签中的colspan
- [CSS]Input标签与图片按钮对齐