Use CSS to create a flip menu in a webpage

Source: Internet
Author: User

If you use the traditional method to make this flip menu, you need to cut the image into at least 10 blocks, add JS code, and add behavior on the image button. Now it is fully implemented using CSS, you only need one image, as shown in the following figure:
CSS code:

The code is as follows: Copy code
# Imgmenu {
Width: Pixel px;
Height: 25px;/* The height is half of the background image */
Background: url (../images/navbg.gif );
List-style-type: none;
Padding: 0px;
Margin: 0px;
}
# Imgmenu li {
Float: left;
}
# Imgmenu li {
Display: block;
Width: 90px;
Height: 25px;
}
# Imgmenu li # home a: hover, # activeh {
Background: url (../images/navbg.gif) 0-25px;
/* Position of the background image during Flip, 0 px on the left,-25px on the top,
The lower part of the background image, the same below */
}
# Imgmenu li # about a: hover, # activea {
Background: url (../images/navbg.gif)-90px-25px;
/* The position of the second menu is 90 PX from the left,
The width of each menu is 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;
}
XHTML:
<Ul id = "imgmenu">
<Li id = "activeh"> <a href = "#"> </a> </li>
<Li id = "about"> <a href = "#"> </a> </li>
<Li id = "pro"> <a href = "#"> </a> </li> <li id = "faq"> <a href = "#"> </a> </li>
<Li id = "contact"> <a href = "#"> </a> </li> </ul>

The design is more considerate, taking care of the friends who browse the plain text: You can set the SPAN element in the LI, add the text link, and set the SPAN invisible in the style.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.