Home  >  Article  >  Web Front-end  >  CSS image flip menu_CSS/HTML

CSS image flip menu_CSS/HTML

WBOY
WBOYOriginal
2016-05-16 12:10:491923browse

If you use the traditional method to make this flip menu, you need to cut the image into at least 10 pieces and add the behavior to the image button using the S code. Now it is completely implemented with CSS. There is only one image. See Picture below.

CSS code:

#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;
}
设计的更体贴,照顾纯文本浏览的朋友:

You can insert the SPAN element in LI, add a text link, and make SPAN invisible in the style.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn