jquery封裝的時間軸

來源:互聯網
上載者:User

jquery封裝的時間軸

概述

很多時候,都會用到類似於時間軸的東西,鑒於網路資源沒有那麼順手,就想著自己搞一個,在此將源碼貼出來。

 

效果

代碼

樣式檔案style.css

 

.timeline{    position: absolute;    z-index: 5000;    font-size: 12px;    border: 1px solid #ccc;    background: whitesmoke;    background: -webkit-linear-gradient(top, whitesmoke, #ddd);    background: -ms-linear-gradient(top, whitesmoke, #ddd);    background: -moz-linear-gradient(top, whitesmoke, #ddd);    border-radius: 4px 0 4px 0;    box-shadow: 0px 0px 10px rgba(150,150,150,0.5);}.timeline ul.ulvec{    margin-left: 10px;    list-style: none;    background: url("dot.gif") 0px 0px repeat-y;    padding-right: 10px;}.timeline ul li.livec{    margin-left: -43px;    padding: 0px 0px 0px 12px;    background: url("biggerdot.png") 0px 50% no-repeat;    cursor: pointer;}.timeline ul.ulhor{    margin: 0px;    padding: 5px 10px;    list-style: none;    background: url("dot.gif") 0px 5px repeat-x;}.timeline ul li.lihor{    display: inline-block;    margin: 0px;    padding: 10px 0px 0px 0px;    margin-top: -3px;    background: url("biggerdot.png") 50% 0px no-repeat;    cursor: pointer;}.timeline ul li span{    display: block;    padding: 4px 15px;    border: 1px solid transparent;}.timeline ul li.active span{    color: #f2f2f2;    box-shadow: inset 0px 0px 30px #333333;    border-radius: 4px;    border: 1px solid #ffffff;    background: #666;}

 

 

控制項代碼 jquery.custom.timeline.js

 

(function($){    $.fn.TimeLine = function(options){        var defaults = {            data:null,            vertical:false        };        var options = $.extend(defaults,options);        var _data = options.data;        var _vertical = options.vertical;        var _showDiv = $(this).addClass("timeline");        var _ul = $("").appendTo(_showDiv); if(_vertical){ _ul.addClass("ulvec"); } else{ _ul.addClass("ulhor"); } for(var i= 0,dl=_data.length;i").appendTo(_ul); if(_vertical){ _li.addClass("livec"); } else{ _li.addClass("lihor"); } var _span = $("").attr("value",_data[i].value).html(_data[i].label).appendTo(_li); _span.on("click",function(){ var _value = this.getAttribute("value"); active(_value); }); } function active(value){ $("li").removeClass("active"); var _spans = $("ul").find("span"); for(var i= 0,dl=_spans.length;i
  • 調用實現

     

     

     

     

     



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.