php之网页选项卡

[html]  view plain  copy
 print ?
  1. 网页选项卡功能:  
[html]  view plain  copy
 print ?
  1. 当鼠标停留超过300毫秒时,自动显示该页面。  
[html]  view plain  copy
 print ?
  1. 效果图:  
[html]  view plain  copy
 print ?
  1. <img src="https://img-my.csdn.net/uploads/201211/10/1352519763_2356.png" alt=""><img src="https://img-my.csdn.net/uploads/201211/10/1352519818_3974.png" alt="">  
[html]  view plain  copy
 print ?
  1. 每个页面的内容都是从数据库中提取的信息。以下是实现代码:  
[html]  view plain  copy
 print ?
  1. html页面代码:  
[html]  view plain  copy
 print ?
  1. <html>  
  2. <head>  
  3. <title>网页选项卡</title>  
  4. <link rel="stylesheet" type="text/css" href="card.css">  
  5. <script src="jquery.js"></script>  
  6. <script src="card.js"></script>  
  7. </head>  
  8. <body>  
  9.     <div id="main">  
  10.         <div id="tit">  
  11.             <h3 class="titin"><a href="card.php?cid=1">第一页</a></h3>  
  12.             <h3 ><a href="card.php?cid=2">第二页</a></h3>  
  13.             <h3 ><a href="card.php?cid=3">第三页</a></h3>  
  14.         </div>  
  15.         <div id="content">  
  16.         
  17.           
  18.         </div>  
  19.     </div>  
  20. </body>  
  21.   
  22. </html>  
  23. php实现数据库查询代码:  
[html]  view plain  copy
 print ?
  1. <p><?<a href="http://lib.csdn.net/base/php" class="replace_word" title="PHP知识库" target="_blank" style="color:#df3434; font-weight:bold;">PHP</a>  
  2.    $cid=$_GET["cid"];  
  3.    $mysqli=new mysqli("localhost","root","family","card");  
  4.      
  5.    $result=$mysqli->query("select title from card where cid=".$cid);  
  6.    while($row=$result->fetch_assoc()){  
  7.     echo '<ul>';  
  8.     echo '<li><a href="con.php?id='.$row["id"].'">'.$row["title"].'</a></li>';  
  9.     echo '</ul>';  
  10.       
  11.    }</p><p>?></p>  
[html]  view plain  copy
 print ?
  1. css修饰页面代码:  
  2.   
  3. body{  
  4.  font-size: 12px;     
  5. }  
  6. #main{  
  7.     width: 300px;  
  8.     height:200px;  
  9. }  
  10. #main h3{  
  11.     width:80px;  
  12.     height:25px;  
  13.     background:#ddd;  
  14.     float:left;  
  15.     margin:0px;  
  16.     padding: 0px;  
  17.     text-align: center;  
  18.     line-height: 25px;  
  19.     font-size: 12px;  
  20.     margin-right: 2px;  
  21.     border:2px solid white ;  
  22. }  
  23. h3 a{  
  24.     color:white;  
  25. }  
  26. #content{  
  27.     background:  #0FC;  
  28.     width: 300px;  
  29.     height:175px;  
  30.     float: left;  
  31. }  
  32. #tit .titin{  
  33.     border: 2px solid  #0FC;      
  34.     background: #0FC;  
  35. }  
  36. javascript实现网页选项卡效果代码:  
[html]  view plain  copy
 print ?
  1. $(function(){  
  2.     $("#content").load("card.php?cid=1");  
  3.     var dt=null;  
  4.     $("#main #tit h3").mouseover(function(){  
  5.         var obj=$(this);  
  6.            dt=setTimeout(function(){  
  7.            obj.addClass("titin").siblings("h3").removeClass("titin");  
  8.            $("#content").load(obj.children("a").eq(0).attr("href"))   
  9.            },300)  
  10.         
  11.          
  12.             
  13.           
  14.     }).mouseout(function(){  
  15.         clearTimeout(dt);  
  16.           
  17.     });  
  18.       
  19.       
  20. });  

转自 http://blog.csdn.net/supersnow0622/article/details/8168779





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值