搜索
SR網頁設計工作室 - 購物網站/企業官網專業開發 Discuz 使用教程 超實用 discuz x2.5 滾動公告效果 DIY程式碼 ...
byadmin 發表於 2013-8-9 21:41:56 , 4236人已閱讀 , 0人回應
筆者最喜歡使用DISCUZ的地方莫過於, 強大的DIY系統 , 它已經將所有動態的程式碼都寫成代碼 , 因此可以很簡單將這些動態的程式碼整合各種前端效果來豐富網站 ! 今天分享一個筆者覺得非常萬用的 滾動公告DIY模塊程式碼, 先來看一下效果吧 :

公告.jpg


DIY程式碼如下:
  1. <style type="text/css">
  2. .effshadow
  3. {
  4.   position: relative;
  5. }
  6. .effshadow:after
  7. {
  8. z-index: -1;
  9. position: absolute;
  10. content: "";
  11. top: 15px;
  12. left: 8px;
  13. right: auto;
  14. width: 50%;
  15. height: 10%;
  16. bottom: 80%;
  17. max-width: 300px;
  18.   background: #777;
  19.   -webkit-box-shadow: 0 15px 10px #777;
  20.   -moz-box-shadow: 0 15px 10px #777;
  21.   box-shadow: 0 15px 10px #777;
  22.   -webkit-transform: rotate(183deg);
  23.   -moz-transform: rotate(183deg);
  24.   -o-transform: rotate(183deg);
  25.   -ms-transform: rotate(183deg);
  26.   transform: rotate(183deg);
  27. }  
  28. .effbox h1{
  29.         text-align:left;
  30.         height:25px;
  31.         line-height:25px;
  32.         position:relative;
  33.         top:0px;
  34.         color:#009ad9;
  35.         font:20px/1.5 Tahoma,'Microsoft Yahei','Simsun';
  36.         float:left;
  37.          margin:0px;
  38. }
  39. .effbox h3{
  40.         text-align:center;
  41.         position:relative;
  42.         font:12px/1.5 Tahoma,'Microsoft Yahei','Simsun';
  43.          margin:0px;
  44.          height:30px;
  45. }
  46. .effbox {
  47.         width:319px;
  48.         height:37px;
  49.         background:#FFF;
  50. }
  51. .shadowcon { width:100%; height:25px; margin:6px 5px 6px 10px; overflow:hidden;}
  52. #rollBox{ height:25px; width:255px; overflow:hidden;list-style:none; margin:0; padding:0; position:relative; padding-left:5px; margin:50px auto; background:#FFf; cursor:pointer;}
  53. .shadowcon li { list-style:none; line-height:25px; text-align:left;}
  54. </style>
  55. <div class="effbox">
  56. <div class="effbox effshadow">
  57.         <div class="shadowcon">
  58.     <h1>公告</h1>
  59.     <h3>
  60.     <ul style="margin:5px 0 0 0;" id="rollBox">
  61.     [loop]
  62.     <li><a href="{url}" title="{title}"{target}>{title}({starttime})</a></li>
  63.     [/loop]
  64.     </ul>
  65.     </h3></div></div></div>
  66.    <script type="text/javascript">
  67. var rollText={
  68.         go:null,
  69.         oParentUl:null,
  70.         oUlH:null,
  71.         liArr:null,
  72.         childNode:null,
  73.         timeout:null,
  74.         run:function(id,delay){
  75.                 var oLiFirst=this.liArr[0];
  76.                 var liMarTop = oLiFirst.style.marginTop;
  77.                 var liTopNum=parseInt(liMarTop);
  78.                 var c = Math.abs(liTopNum);
  79.                 if(c< parseInt(this.oUlH)){
  80.                         c++;
  81.                         oLiFirst.style.marginTop ='-' + c + 'px';
  82.                 }else if(Math.abs(liTopNum)== parseInt(this.oUlH)){
  83.                         clearInterval(this.go);
  84.                         this.oParentUl.removeChild(oLiFirst);
  85.                         this.oParentUl.appendChild(oLiFirst);
  86.                         this.liArr[this.liArr.length-1].style.marginTop='0px';
  87.                         this.timeout=setTimeout(function(obj,id,childtags,delay){return function(){obj.start(id,childtags,delay);};}(this,id,this.childNode,delay),delay);
  88.                 }
  89.                
  90.         },
  91.         start:function(id,childtags,delay){
  92.                
  93.                 this.childNode=childtags;
  94.                 this.oParentUl=document.getElementById(id);
  95.                 this.oUlH=this.oParentUl.currentStyle?this.oParentUl.currentStyle['height']:window.getComputedStyle(this.oParentUl,null)['height'];
  96.                 this.liArr=this.oParentUl.getElementsByTagName(childtags);
  97.                 for(var i=0;i<this.liArr.length;i++){
  98.                         this.liArr[i].style.cssText +=';margin-top:0;height:'+this.oUlH+';line-height:'+this.oUlH+';display:block; width:100%;';
  99.                         
  100.                 }
  101.                 this.go =setInterval(
  102.                          function(obj,id,delay){
  103.                         return function(){obj.run(id,delay)}
  104.                 }(this,id,delay),10);
  105.                 this.oParentUl.onmouseover=function(obj){return function(){clearTimeout(obj.timeout);clearTimeout(obj.go);};}(this);
  106.                 this.oParentUl.onmouseout=function(obj){return function(){obj.go =setInterval(function(obj,id,delay){return function(){obj.run(id,delay)};}(obj,id,delay),10);};}(this);
  107.                
  108.         }
  109. }
  110. rollText.start('rollBox','li',3000);
  111. function clone(){};
  112. clone.prototype= rollText;
  113. </script>
複製代碼
DIY如何自行添加程式碼筆者就不贅述囉 , 請大家自行至官方網站多多爬文囉 :)

收藏回覆 只看該作者 道具 舉報

Traffic Exchange Site
您需要登錄後才可以回帖 登錄 | 立即註冊

作者資訊

文章分類

SR數位設計工作室

  • 服務專線:03-3555-069


ECSHOP購物網站開發|接案說明|線上洽詢|隱私權政策|SR數位設計(CMS)

信箱:sr.design2011@gmail.com

, Processed in 0.154782 second(s), 47 queries , Gzip On.

Copyright © 2011-2014 Template By SR網頁設計清新部落風格

Core - DZ2.5 GMT+8, 2024-4-20 02:42

回頂部