使用 jQuery & CSS3 實現優雅的手風琴效果

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   color   ar   os   使用   

  手風琴效果常用於切換顯示一組內容,這種方式既可以節省網頁空間又可以有動畫效果。今天,我們將創造一個優雅的手風琴內容效果。這個想法是有懸停時滑出一些垂直手風琴標籤。我們將添加一些 CSS3 屬性來提升外觀。

 

 

效果示範     外掛程式下載

 

HTML範例程式碼:

<ul class="accordion" id="accordion">    <li class="bg1">        <div class="heading">Heading</div>        <div class="bgDescription"></div>        <div class="description">            <h2>Heading</h2>            <p>Some descriptive text</p>            <a href="#">more ?</a>        </div>    </li></ul>

CSS範例程式碼:

ul.accordion li .description h2{    text-transform:uppercase;    font-style:normal;    font-weight:bold;    letter-spacing:1px;    font-size:45px;    color:#444;    text-align:left;    margin:0px 0px 15px 20px;    text-shadow:-1px -1px 1px #ccc;}ul.accordion li .description p{    line-height:14px;    margin:10px 22px;    font-family: "Trebuchet MS", sans-serif;    font-size: 12px;    font-style: italic;    font-weight: normal;    text-transform: none;    letter-spacing: normal;    line-height: 1.6em;}ul.accordion li .description a{    position:absolute;    bottom:5px;    left:20px;    text-transform:uppercase;    font-style:normal;    font-size:11px;    text-decoration:none;    color:#888;}ul.accordion li .description a:hover{    color:#333;    text-decoration:underline;}

JavaScript代碼:

$(function() {    $(‘#accordion > li‘).hover(        function () {            var $this = $(this);            $this.stop().animate({‘width‘:‘480px‘},500);            $(‘.heading‘,$this).stop(true,true).fadeOut();            $(‘.bgDescription‘,$this).stop(true,true).slideDown(500);            $(‘.description‘,$this).stop(true,true).fadeIn();        },        function () {            var $this = $(this);            $this.stop().animate({‘width‘:‘115px‘},1000);            $(‘.heading‘,$this).stop(true,true).fadeIn();            $(‘.description‘,$this).stop(true,true).fadeOut(500);            $(‘.bgDescription‘,$this).stop(true,true).slideUp(700);        }    );});

  

您可能感興趣的相關文章
  • Web 開發中很實用的10個效果【源碼下載】
  • 精心挑選的優秀jQuery Ajax分頁外掛程式和教程
  • 12個讓人驚歎的的創意的 404 錯誤頁面設計
  • 讓網站動起來!12款優秀的 jQuery 動畫外掛程式
  • 十分驚豔的8個 HTML5 & JavaScript 特效

 

本文連結:使用 jQuery 和 CSS3 實現優雅的手風琴效果

編譯來源:夢想天空 ◆ 關注前端開發技術 ◆ 分享網頁設計資源

使用 jQuery & CSS3 實現優雅的手風琴效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.