JSP+css标签页

本文转自:点击打开链接


习惯了js框架ext,jquery等。突然要用jsp+css实现标签页的效果,突然不适应了,在网上so了一下发现一个不错的实现方式,现引用一下:原版请参考:http://blog.csdn.net/uniorg/article/details/3176266,

Html代码   收藏代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>标签示例</title>  
  6. <style type="text/css">  
  7. body { font-size:14px; font-family:"宋体"}  
  8. ol li { margin:8px}  
  9. #con { font-size:12px; width:600px; margin:0 auto}  
  10. #tags { height:23px; width:400px; margin:0; padding:0; margin-left:10px}  
  11. #tags li { float:left; margin-right:1px; background:url(images/tagleft.gif) no-repeat left bottom; height:23px; list-style-type:none}  
  12. #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}  
  13. #tags li.emptyTag { width:4px; background:none}  
  14. #tags li.selectTag { background-position: left top; position:relative; height:25px; margin-bottom:-2px}  
  15. #tags li.selectTag a { background-position: right top; color:#000; height:25px; line-height:25px;}  
  16. #tagContent { padding:1px; background-color:#fff; border:1px solid #aecbd4;}  
  17. .tagContent { background:url(images/bg.gif) repeat-x;  padding:10px; color:#474747; width:576px; display:none}  
  18. #tagContent div.selectTag{ display:block}  
  19.   
  20. </style>  
  21. </head>  
  22. <body>  
  23. <h1>标签示例</h1>  
  24. <ol>  
  25.     <li>使用JS实现tab标签效果</li>  
  26.     <li>标签宽度随文字的数量自适应</li>    
  27.     <li>支持 IE、Firefox、Chrome、Safari、opera</li>  
  28.       
  29.       
  30. </ol>  
  31. <div id="con">  
  32.   <ul id="tags">  
  33.     <li><a href="javascript:void(0)" onclick="selectTag('tagContent0',this)">标签一</a></li>  
  34.     <li class="selectTag"><a href="javascript:void(0)" onclick="selectTag('tagContent1',this)">标签二</a></li>  
  35.     <li><a href="javascript:void(0)" onclick="selectTag('tagContent2',this)">自适应宽度的标签</a></li>  
  36.   </ul>  
  37.   <div id="tagContent">  
  38.     <div id="tagContent0" class="tagContent">第一个标签的内容<br />第一个标签的内容<br />第一个标签的内容</div>  
  39.     <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>  
  40.     <div id="tagContent2" class="tagContent">第三个标签的内容<p>放大观看标签背景图:<img src="images/tagleft.gif" align="top" width="300" height="100"></p></div>  
  41.   </div>    
  42. </div>  
  43. <script type="text/javascript">  
  44. function selectTag(showContent,selfObj){  
  45.     selfObj.blur();  
  46.     // 操作标签  
  47.     var tag = document.getElementById("tags").getElementsByTagName("li");  
  48.     var tagtaglength = tag.length;  
  49.     for(i=0; i<taglength; i++){  
  50.         tag[i].className = "";  
  51.     }  
  52.     selfObj.parentNode.className = "selectTag";  
  53.     // 操作内容  
  54.     for(i=0j=document.getElementById("tagContent"+i); i++){  
  55.         j.style.display = "none";  
  56.     }  
  57.     document.getElementById(showContent).style.display = "block";  
  58.       
  59.       
  60. }  
  61. </script>  
  62. </body>  
  63. </html>  

 效果如图:

标签页

  • 大小: 20.9 KB

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值