Home Web Front-end JS Tutorial jquery implements smooth secondary drop-down menu effect_jquery

jquery implements smooth secondary drop-down menu effect_jquery

May 16, 2016 pm 03:42 PM
jquery Secondary drop-down menu

The example in this article describes the smooth secondary drop-down menu effect achieved by jquery. Share it with everyone for your reference. The details are as follows:

This is a secondary menu effect implemented using jQuery. It has a gray style. If you don’t like the color, just do it yourself. The CSS code has been optimized. If you are good at it, you can modify it yourself. This is a The navigation menu effect found on foreign front-end design websites, I hope you like it.

The screenshot of the running effect is as follows:

The online demo address is as follows:

http://demo.jb51.net/js/2015/jquery-soft-2level-menu-nav-codes/

The specific code is as follows:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

<!DOCTYPE html>

<head>

<title>jquery平滑二级下拉菜单</title>

<style>

h1, h2, h3, h4, p, li, li a{font-family: Arial, Sans-Serif;font-size: 15px;font-weight: bold;color: #525252;text-decoration: none;}

h1, h2, h3, h4{font-size: 22px;}

#dropdown_nav{width: 960px;padding: 0px;display: inline-block;list-style: none;-moz-box-shadow: inset 0px 0px 1px #fff;-webkit-box-shadow: inset 0px 0px 1px #fff;border: 1px solid #ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;background: #e2e2e2;background: -moz-linear-gradient(#f3f3f3, #e2e2e2);background: -webkit-gradient(linear, 0 0, 0 100%, from(#f3f3f3), to(#e2e2e2));}

#dropdown_nav li{padding: 10px 0px 10px 0px;float: left;position: relative;display: inline-block;}

#dropdown_nav li a{padding: 10px 15px 10px 15px;text-shadow: -1px 1px 0px #f6f6f6;-moz-box-shadow: inset 0px 0px 1px #fff;-webkit-box-shadow: inset 0px 0px 1px #fff;border-right: 1px solid #ccc;}

#dropdown_nav li a: hover{background: #f9f9f9;background: -moz-linear-gradient(#f9f9f9, #e8e8e8);background: -webkit-gradient(linear, 0 0, 0 100%, from(#f9f9f9), to(#e8e8e8));}

#dropdown_nav li a: active{background: #e2e2e2;background: -moz-linear-gradient(#e2e2e2, #f3f3f3);background: -webkit-gradient(linear, 0 0, 0 100%, from(#e2e2e2), to(#f3f3f3));}

#dropdown_nav li a.first{-moz-border-radius: 5px 0px 0px 5px;-webkit-border-radius: 5px 0px 0px 5px;}

#dropdown_nav .sub_nav{width: 160px;padding: 0px;position: absolute;top: 38px;left: 0px;border: 1px solid #ccc;background: #e2e2e2;}

#dropdown_nav .sub_nav li{width: 160px;padding: 0px;}

#dropdown_nav .sub_nav li a{display: block;border-bottom: 1px solid #ccc;background: -moz-linear-gradient(#f3f3f3, #e2e2e2);background: -webkit-gradient(linear, 0 0, 0 100%, from(#f3f3f3), to(#e2e2e2));}

#dropdown_nav .sub_nav li a: hover{background: #f9f9f9;background: -moz-linear-gradient(#f9f9f9, #e8e8e8);background: -webkit-gradient(linear, 0 0, 0 100%, from(#f9f9f9), to(#e8e8e8));}

#dropdown_nav .sub_nav li a: active{background: #e2e2e2;background: -moz-linear-gradient(#e2e2e2, #f3f3f3);background: -webkit-gradient(linear, 0 0, 0 100%, from(#e2e2e2), to(#f3f3f3));}

</style>

<script type="text/javascript" src="jquery-1.6.2.min.js"></script>

<script type="text/javascript">

  $(function() {

   //We initially hide the all dropdown menus

   $('#dropdown_nav li').find('.sub_nav').hide();

   //When hovering over the main nav link we find the dropdown menu to the corresponding link.

   $('#dropdown_nav li').hover(function() {

    //Find a child of 'this' with a class of .sub_nav and make the beauty fadeIn.

    $(this).find('.sub_nav').fadeIn(100);

   }, function() {

    //Do the same again, only fadeOut this time.

    $(this).find('.sub_nav').fadeOut(50);

   });

  });

 </script>

</head>

<body>

 <h2>Creating an Awesome Drop-Down Nav with CSS3 & jQuery</h2>

 <ul id="dropdown_nav">

  <li><a class="first" href="#">Home</a></li>

  <li><a href="#">ASP源码下载</a>

   <ul class="sub_nav">

    <li><a href="#">新闻类</a></li>

    <li><a href="#">论坛类</a></li>

    <li><a href="#">企业类</a></li>

   </ul>

  </li>

  <li><a href="#">技术文章</a>

   <ul class="sub_nav">

    <li><a href="#">ASP</a></li>

    <li><a href="#">php</a></li>

    <li><a href="#">jquery</a></li>

    <li><a href="#">Ajax</a></li>

   </ul>

  </li>

  <li><a href="#">Freebies</a>

  </li>

  <li><a class="last" href="#">网页特效</a>

   <ul class="sub_nav">

    <li><a href="#">导航菜单</a></li>

    <li><a href="#">CSS布局</a></li>

    <li><a href="#">鼠标特效</a></li>

   </ul>

  </li>

 </ul><br />

</body>

</html>

Copy after login

I hope this article will be helpful to everyone’s jquery programming design.

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to add a secondary drop-down menu to a wps table - steps to add a drop-down menu to a wps table How to add a secondary drop-down menu to a wps table - steps to add a drop-down menu to a wps table Mar 27, 2024 pm 12:11 PM

1. Open the table file and enter the text that needs to be set as a drop-down list. Select the formula in the menu bar and click the Specify button in the property bar. 2. Choose the appropriate creation method according to your own situation. Here, select the first row and uncheck the others. 3. Find the cell column where the drop-down list is placed, select it, select the data option in the menu bar, and click Validity in the property bar. 4. Set the valid condition permission to sequence and the source to the first row. Just drag the mouse to select it. It also represents the content of the first-level drop-down list. Click OK. 5. Select the cell where the secondary drop-down list is placed and click Validity on the property bar. 6. Also set the allowed conditions to sequence, set the source to =INDIRECT(G1), click OK, G1 here is a

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: &lt

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on ​​the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to tell if a jQuery element has a specific attribute? How to tell if a jQuery element has a specific attribute? Feb 29, 2024 am 09:03 AM

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s

See all articles