Wordpress CSS to implement the drop-down menu

Source: Internet
Author: User

Recently, many friends in the group have installed the ssmay topic and it feels good. However, some friends have suggested why there is no drop-down menu for the ssmay topic. At that time, I did not care, because this topic was designed according to my own needs. Later, some friends mentioned this. I think so too. Why don't I get a drop-down menu for the ssmay topic? In this way, the website is not made more human-more types can be displayed. In fact, there are several ways to implement the drop-down menu, such as JS implementation, plug-in implementation, and CSS implementation. Here, I will introduce the simple implementation of drop-down menu effects through CSS.

First, set the menu.

Go to the background --> appearance --> menu, create a menu, and add the category directory to this menu. Here we will not talk about it much. Then, we will display the level-2 menu (or sub-category) you want to display) move to its level-1 menu (or parent category), as shown in the following figure. PHP development uses the parent category and website construction uses the subcategory.

If the topic you are using is an Ssmay 1.1 topic, your menu here is the drop-down menu, and it will end here. If you want to study it, you can continue to look down.

Then, modify the code of the navigation menu of the header file and replace the original navigation menu code with the following code.

The code is as follows: Copy code

<? Php wp_nav_menu (array ('container' => ", 'items _ wrapp' => '<ul id = "nav" class = "menu"> % 3 $ s </ul> ', 'Fallback _ cb '=> ");?>

The last step is to set the relevant CSS code, and put the following code in the style.css file.

 

The code is as follows: Copy code
/* Drop-down menu */
# Nav {
Background: #222;
Font-size: 1.1em;
}
# Nav, # nav ul {
List-style: none;
Line-height: 1;
}
# Nav a, # nav a: hover {
Display: block;
Text-decoration: none;
Border: none;
}
# Nav li {
Float: left;
List-style: none;
Border-right: 1px solid # a9a9a9;
}
# Nav a, # nav a: visited {
Display: block;
Font-weight: bold;
Color: # f5f5f4;
Padding: 0px 0px;
}
# Nav a: hover, # nav a: active,. current_page_item a, # home. on {
Background: #000;
Text-decoration: none
}
# Nav li ul {
Position: absolute;
Left:-999em;
Height: auto;
Width: 90px;
Border-bottom: 1px solid # a9a9a9;
}
# Nav li {
Width: 90px;
Border-top: 1px solid # a9a9a9;
Border-right: 1px solid # a9a9a9;
Border-left: 1px solid # a9a9a9;
Background: #777;
}
# Nav li a, # nav li a: visited {
Font-weight: normal;
Font-size: 0.9em;
Color: # FFF;
}
# Nav li a: hover, # nav li a: active {
Background: #000;
} Www.111cn.net
# Nav li: hover ul, # nav li. sfhover ul, # nav li. sfhover ul, # nav li. sfhover ul {
Left: auto;
}
A. main: hover {
Background: none;
}

In this way, the drop-down menu is implemented. Of course, I only implement the level-2 drop-down menu here, but not the level-3 drop-down menu. If you want to implement the level-3 drop-down menu, you can do it further. However, I don't think it is necessary to set the wordpress website to a three-level drop-down menu, because the site is generally not too large. Haha, although such a drop-down menu is not cool as designed by JS, it is better than SEO.

 

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.