一款漂亮的純CSS手風琴效果代碼

來源:互聯網
上載者:User

本文分享了純css實現的手風琴,喜歡的朋友可以看看

源碼CSS部分

.accordionMenu {width: 500px;margin: 0 auto;padding: 10px;background-size: #fff;color: #424242;font: 12px Arial, Verdana, sans-serif;}.accordionMenu h2 {position: relative;margin: 5px 0;padding: 0;}.accordionMenu h2:before { /*製作向下三角效果*/position: absolute;top: 15px;right: 10px;width: 0;height: 0;border: 5px solid #fff;border-color: #fff transparent transparent;content: "";}.accordionMenu h2 a { /*製作手風琴標題列效果*/background: #8f8f8f;background: -moz-linear-gradient(top, #cecece, #8f8f8f);background: -webkit-gradinet(linear, left top,left bottom, from(#cecece),to(#8f8f8f));background: -webkit-linear-gradient(top, #cecece, #8f8f8f);background: -o-linear-gradient(top, #cecece, #8f8f8f);background: linear-gradient(top, #cecece, #8f8f8f);border-radius: 5px;color: #424242;display: block;font-size: 13px;font-weight: normal;margin: 0;padding: 10px 10px;text-shadow: 2px 2px 2px #aeaeae;text-decoration: none;}.accordionMenu :target h2 a, /*目標標題的效果*/.accordionMenu h2 a:focus,.accordionMenu h2 a:hover,.accordionMenu h2 a:active {background: #2288dd;background: -moz-linear-gradient(top, #6bb2ff, #2288dd);background: -webkit-gradinet(linear, left top, left bottom,from(#6bb2ff), to(#2288dd));background: -webkit-linear-gradient(top, #6bb2ff, #2288dd);background: -o-linear-gradient(top, #6bb2ff, #2288dd);background: linear-gradient(top, #6bb2ff, #2288dd);color: #fff;}.accordionMenu p { /* 標題列對應的內容 */overflow: hidden;height: 0; /*預設欄目內容高度為0,達到隱藏效果*/margin: 0;padding: 0 10px;-webkit-transition: height 0.5s ease-in;-moz-transition: height 0.5s ease-in;-o-transition: height 0.5s ease-in;transition: height 0.5s ease-in;}/*關鍵代碼 顯示內容部分資訊*/.accordionMenu :target p { /*展開對應目標內容*/overflow: hidden;height: 20px;/*顯示對應目標欄內容*/}.accordionMenu :target h2:before { /*展開時標題三角效果*/border-color: transparent transparent transparent #fff;}

源碼html部分

<p class="accordionMenu"><p class="menuSection" id="brand"><h2><a href="#brand">Brand</a></h2><p>Lorem ipsum dolor...</p></p><p class="menuSection" id="promotion"><h2><a href="#promotion">promotion</a></h2><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p></p><p class="menuSection" id="Event"><h2><a href="#Event">Event</a></h2><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p><p>Lorem ipsum dolor sit amet...</p></p></p>

更多CSS3特效代碼請關註:http://www.php.cn/xiazai/js/CSS3

相關文章

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.