CSS圖片翻轉菜單

來源:互聯網
上載者:User

如果用傳統的方法製作這個翻轉菜單,至少需要把圖片切成10椋掛由螶S代碼,在圖片按鈕上再加行為,現在完全用CSS來實現,圖片只要一張,見。

CSS代碼:

#imgmenu{ width: 450px; height: 25px; /*高度是背景圖片的一半*/ background: url(../images/navbg.gif); list-style-type: none; padding: 0px; margin: 0px;} #imgmenu li{ float: left;} #imgmenu li a{ display: block; width: 90px; height: 25px;} #imgmenu li#home a:hover,#activeh{ background: url(../images/navbg.gif) 0 -25px;  /*翻轉時背景圖的位置,左邊0px,頂部-25px, 背景圖的下半部分,下同*/} #imgmenu li#about a:hover,#activea{ background: url(../images/navbg.gif) -90px -25px; /*第二個菜單的位置距左邊90px, 每個菜單的寬度是90px*/} #imgmenu li#pro a:hover,#activep{ background: url(../images/navbg.gif) -180px -25px;} #imgmenu li#faq a:hover,#activef{ background: url(../images/navbg.gif) -270px -25px;} #imgmenu li#contact a:hover,#activec{ background: url(../images/navbg.gif) -360px -25px;}
設計的更體貼,照顧純文字瀏覽的朋友:

可以在LI內套入SPAN元素,加入文本連結,在風格中設SPAN不可見。

相關文章

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.