How to use display:olck/none to create a menu bar

How to use display:olck/none to create a menu bar

The effect of completing a menu bar through display:bolck/none Figure 1:

First, here is a completed effect. When we move the mouse into the "menu" area, it will pop up. The effect of Figure 2

insert image description here

Figure 2:

On the contrary, if we move the mouse out of the "Menu" area, the submenu below will be hidden, and we will get the effect shown in Figure 1.

insert image description here

Figure 3:

The source code in the figure is the implementation of the content style structure of Figure 1 and Figure 2. We first give a large div to make a large box for the displayed content, and put 5 divs in the box to complete the content to be presented. Then set a "left float" style for these 5 divs so that they can be arranged side by side in a row. Of course, you can also set it to an "inline block-level element" and put an "unordered list" in it to present the content of the submenu.

insert image description here

Figure 4:

1. Let's set some basic styles for the top li first, give this tag an (absolute positioning) position: relative; then set a (relative positioning) position: absolute for its subordinate ul; 2. Set the |display| of this ul to |none| to hide it - refer to Figure 5 - U2 part. 3. Then set the (pseudo-class) hover to call the class name of the subordinate ul, and set the | display | of ul to | block | —— Figure 4 —— Realize that when the mouse moves over this li, the subordinate ul will be displayed

insert image description here

Figure 5:

Finally, if you feel the effect is a bit stiff, we can use @keyframes to set the transform animation effect and set the animation effect we want according to our own preferences.

insert image description here

This is the end of this article on how to complete a menu bar through display:olck/none. For more relevant display:olck/none menu bar content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  HTML basic summary recommendation (text format)

>>:  Tutorial on installing MySQL under Linux

Recommend

Better-scroll realizes the effect of linking menu and content

1. Basic use <!DOCTYPE html> <html lang=...

A brief analysis of the responsiveness principle and differences of Vue2.0/3.0

Preface Since vue3.0 was officially launched, man...

Solution to prevent caching in pages

Solution: Add the following code in <head>: ...

How to install Element UI and use vector graphics in vue3.0

Here we only focus on the installation and use of...

Implementing long shadow of text in less in CSS3

This article mainly introduces how to implement l...

SQL function to merge a field together

Recently, I need to query all the fields in a rel...

Summary of commonly used operators and functions in MySQL

Let’s build the data table first. use test; creat...

Javascript to achieve drumming effect

This article shares the specific code of Javascri...

Detailed explanation of slave_exec_mode parameter in MySQL

Today I accidentally saw the parameter slave_exec...

Solve nginx "504 Gateway Time-out" error

Students who make websites often find that some n...

Detailed explanation of JDBC database link and related method encapsulation

Detailed explanation of JDBC database link and re...

In-depth analysis of MySQL index data structure

Table of contents Overview Index data structure B...

Implementation of MySQL index-based stress testing

1. Simulate database data 1-1 Create database and...